How to return/use VERY LARGE numbers?

This is a discussion on How to return/use VERY LARGE numbers? within the C++ Programming forums, part of the General Programming Boards category; This is in VC++ 6.0 THe problem i'm having is that it's screwing up wiht extremely large numbers. e.g., cout ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    13

    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.
    Last edited by 99atlantic; 04-05-2005 at 07:36 PM.

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    __int64's are alot larger
    For even larger numbers check out gmp

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    13
    __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
    Last edited by 99atlantic; 04-05-2005 at 07:55 PM.

  4. #4
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    This is in VC++ 6.0
    Hmm, __int64 is known to VC++ 6.0, in fact, it even gets turned blue =)

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    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.

  6. #6
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    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

  7. #7
    Registered User
    Join Date
    Apr 2005
    Posts
    13
    Quote Originally Posted by MadCow257
    Hmm, __int64 is known to VC++ 6.0, in fact, it even gets turned blue =)
    well i've never used it until today

    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 :/
    Last edited by 99atlantic; 04-05-2005 at 08:31 PM.

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Why can't you write the program which uses the dll to expect a double as the return type?

  9. #9
    Registered User
    Join Date
    Apr 2005
    Posts
    13
    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)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to deal wth large numbers
    By bvgsrs in forum C++ Programming
    Replies: 2
    Last Post: 06-18-2007, 06:16 AM
  2. Handling Large Numbers
    By Xzyx987X in forum C Programming
    Replies: 2
    Last Post: 05-03-2004, 02:33 PM
  3. Using really big numbers!
    By Machewy in forum C++ Programming
    Replies: 11
    Last Post: 02-26-2004, 09:49 AM
  4. Help needed with VERY large numbers.
    By jwarner in forum C++ Programming
    Replies: 4
    Last Post: 01-18-2004, 11:01 AM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 05:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21