CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2006
    Posts
    86

    1024+ Digit Decimal/Double!

    How do you perform an operation on a very long Decimal (or Double), if you need more digits than Decimal can handle and you do not want it in exponential notation... for example, computing pi or e or phi?

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: 1024+ Digit Decimal/Double!

    There are infinite precision classes available, but most of them are for C++.

    The basic idea is you use a dynamic array of digits, and write all of the math operations.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Dec 2003
    Location
    Middletown, DE
    Posts
    67

    Re: 1024+ Digit Decimal/Double!

    What class(es) do you recommend?

  4. #4
    Join Date
    Dec 2006
    Posts
    86

    Re: 1024+ Digit Decimal/Double!

    Like I can write math operations!
    Two things:
    1. Wouldn't math operations in VB.NET be very inefficient? (For instance, in a graphing software)
    2. Could someone help me define exponentiation/logarithms with the array?

    Thanks.

  5. #5
    Join Date
    Dec 2006
    Posts
    86

    Re: 1024+ Digit Decimal/Double!

    I started to create my own class, using a Byte array.
    Can someone tell me how to define powers and other things?
    I know how to define sin, cos, etc., because of the series, but what about powers and division? Can someone help? Thanks.

  6. #6
    Join Date
    Jan 2006
    Posts
    293

    Re: 1024+ Digit Decimal/Double!

    I remember seeing a post a while back on the MSDN forums over dealing with long numbers, and was able to find it here, if it helps at all...

  7. #7
    Join Date
    Dec 2006
    Posts
    86

    Re: 1024+ Digit Decimal/Double!

    Thanks a lot, I'll look at it.
    After taking a quick glance, though, I don't get how to make an array that accepts bounds greater than Integer.MaxValue... any idea?

    FYI: I'm creating a class named UnlimitedDecimal which uses BitConverter... should I make it a structure instead?

  8. #8
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: 1024+ Digit Decimal/Double!

    an array that accepts bounds greater than Integer.MaxValue
    OK, I understand long integer numbers (many digits), but mote than 4,294,967,296 digits????
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  9. #9
    Join Date
    Dec 2006
    Posts
    86

    Re: 1024+ Digit Decimal/Double!

    Oops - I thought that integer.max_value = 10^16... (this was not because of VB6).
    I'll post any questions later.
    Thanks all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured