Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Arbitrary Precision

Arbitrary Precision
Thread Tools
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Feb 4, 2001, 11:21 AM
 
This isn't about X really, but does anyone know any good resources for Arbitrary Precision mathematics (in C)?
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Feb 4, 2001, 03:39 PM
 
I don't think it's truly arbitrary precision, but you could look at Foundation's NSDecimal (and NSDecimalNumber, the object version). It can
certiainly handle much more than a double.

If you don't mind the GPL issues, there is gmp, the GNU MP library. There seems to be a darwin version at http://www.hyperdigm.com/downloads.htm

Past that, dunno. A Google search turned up this page - http://munitions.iglu.cjb.net/dolphi...;category=0302

No idea which of those, if any, has been ported/compiled for Darwin/MacOS X.
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Feb 4, 2001, 05:58 PM
 
Thanks lindberg.

I have no problems with GPL, but I either want to do it for it my own pride or use an NS Class. I'll check out NSDecimal.

An instance can represent any number that can be expressed as mantissa x 10exponent where mantissa is a decimal integer up to 38 digits long, and exponent is an integer between -128 and 127.
Hmm... That's pretty cool, but I wonder why Apple didn't make an NS class (or is there?) for arbitrary precision.
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Feb 4, 2001, 10:36 PM
 
NSDecimalNumber (subclass of NSNumber) is the object version of
NSDecimal. Using NSDecimal structures directly is faster and uses
less memory, but is probably more cumbersome to code. If you're
doing lots and lots of calculations that can tie up the CPU, you'll
probably want to use NSDecimal. Otherwise, it's really whichever
you find easier.
     
Fresh-Faced Recruit
Join Date: Jan 2001
Status: Offline
Reply With Quote
Feb 24, 2001, 04:01 AM
 
If you want arbitrary precision try bc. By that I mean download the source for bc from gnu.org and get the number.c library out of that. I don't know how fast it really is but it is definitely arbitrary precision. I did 9999999^999 and it spouted out about 3 pages of answer.

peter
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:18 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2