# How to return/use VERY LARGE numbers?

• 04-05-2005
99atlantic
How to return/use VERY LARGE numbers?
This is in VC++ 6.0

THe problem i'm having is that it's screwing up wiht extremely large numbers.

e.g., cout << 123546*654321 returns a VERY wrong number.

So my next thought was to go like

float x = 123456;
float y = 654321;
double z = x*y;
cout << z;

Okay, now I run into a new problem - C++ when it outputs it is rounding the number.....I need the UNROUNDED number (i.e., not, for example, 8.07799*e^20, but 8077985334534........)

Can anybody offer some insight?

edit: the reason I say I need the unrounded number is because if I take that number and pass it to another function, somehow it's warped in memory from the rounding and is displayed with 99% accuracy.

e.g., it will display 12345678 instead of 12345690...althogh a difference on only 12 on the last 2 digist, for my line of work this is a HUGE error.
• 04-05-2005
__int64's are alot larger
For even larger numbers check out gmp
• 04-05-2005
99atlantic
__int64? i am unfamiliar with said term. you wouldn't hapeen to have a resource for it so I could understand how to implement it? Thanks.

Okay, I googled for it and roughly understand it, but I'm running into a problem - even if it stores it accurately, how can i export it form a DLL? the program i'm using only understands the types

int (short/long)
void
float
double
long

all the standards. Hmm perplexing
• 04-05-2005
Quote:

This is in VC++ 6.0
Hmm, __int64 is known to VC++ 6.0, in fact, it even gets turned blue =)
• 04-05-2005
Quantum1024
A float has a floating point (decimel point) and a double dosen't which explains the rounding. I am fairly sure a double is the same as a __int64.
• 04-05-2005
Quote:

I am fairly sure a double is the same as a __int64
I would disagree. __in64 is integral while double is floating.

http://msdn.microsoft.com/library/de...reftable_1.asp
• 04-05-2005
99atlantic
Quote:

Hmm, __int64 is known to VC++ 6.0, in fact, it even gets turned blue =)

well i've never used it until today :p

okay, so I got it working and it works with 100% accuracy. so that's good. nwo the problem is going to be to figure out how to export it out so another program that doesn't have __int64 capacity will be able to read it. Hmmm

edit: and of course my luck isn't that great - i can't store the number as an __in64, then then return it as an __int64, but have the program calling the dll receive it as a double or float. Greaaaat, lol. THis is so not fun :/
• 04-05-2005
Quantum1024
Why can't you write the program which uses the dll to expect a double as the return type?
• 04-05-2005
99atlantic
Quote:

Originally Posted by Quantum1024
Why can't you write the program which uses the dll to expect a double as the return type?

that doesn't work in this case.

if it expects a double, it gets the "rounded" form of the number (e.g., 1234567801 isntead of 1234567891)