Link to home
Start Free TrialLog in
Avatar of bebonham
bebonham

asked on

FUN Q!! strange math

okay, well, maybe it's fun for those of you who like math puzzles, I DO NOT!!

so here it is ... there is this struct I am trying to use from OLE DB or something...it came from the database

it is

#ifndef _tagCY_DEFINED
#define _tagCY_DEFINED
#define _CY_DEFINED
#if 0
/* the following isn't the real definition of CY, but it is */
/* what RPC knows how to remote */
typedef struct  tagCY
    {
    LONGLONG int64;
    }     CY;

#else /* 0 */
/* real definition that makes the C++ compiler happy */
typedef union tagCY {
    struct {
#ifdef _MAC
        long      Hi;
        long Lo;
#else
        unsigned long Lo;
        long      Hi;
#endif
    };
    LONGLONG int64;
} CY;


anyways...

so I can access Hi and Lo as part of that struct (and also int64)

and they are all basiclly interger type things.
(supposed to be currency)

anyways,

if I put a number like 999,999 in I get this

.Lo = 9999990000
.Hi = 0
.int64 = 9999990000

if I put 10 in there I would 100,000 I would get
.Lo = 1000000000
.Hi=0
.int64 = 1000000000

if I put 1,000,000 HOWEVER,
I get
.Lo=1215752192
.Hi=23
.int64=1215752192

if I put 12,345,678 in I get
.Lo=3197695712
.Hi=28
.int64=3197695712




so, I am trying to figure out what .Hi is doing, and how to figure out what the decimal number is contained in something like that.

any ideas???

please help,

I will be glad to give you the results of Hi Lo, and int64 for any decimal number you like.

Bob
Avatar of bebonham
bebonham

ASKER

okay here is a wierd one that may help:

lo=0
int64=0
hi=1

the decimal value is
429496.7296

what the heck!!
Avatar of jkr
That's funny - I tried

#include <windows.h>
#include <iostream>
using namespace std;

typedef union tagCCY {
   struct {
#ifdef _MAC
       long      Hi;
       long Lo;
#else
       unsigned long Lo;
       long      Hi;
#endif
   };
   LONGLONG int64;
} CCY;

void main () {

 CCY cy;
 cy.int64 = 1234567;

 cout << "Hi." << cy.Lo << endl;
 cout << "Lo." << cy.Hi << endl;
}

and it works (CCY because there already seems to be the "original" CY included...)
oh, and 123 in decimal would be

lo=1230000
int64 = 1230000
and hi=0

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oh yeah, probably I have not explained well enough,

see, I tried linking up to this .mdb using ole db (jet 3.51)

and now I am trying to change data in there.
and that struct is giving me a problem.

maybe it is being manipulated somewhere else??

I am so ignorant of how this all works...do you see what I mean though?

I see the mdb database and there is only one value for the "appraised value"
not a hi, lo and int64

when I try to set the value of int64, it does not work also...not sure this is meaningful.

keep in mind I didn't write any of that code, it all came from MFC when I included database support.

sorry I may be rambling, but certainly appreciate the help so far, I will test the CY struct in a little program, that is a good idea.  Any other ideas you may have are welcome

Thanks,

Bob
the totaly nutz answer is

429496.7296 * .Hi

+

.Lo/10000

= decimal value



I think these people are on drugs.

Sorry JKR, I probably asked that so wrong you never had a chance

but test it ... it works :)!!


Bob