 |
 |
Arbitrary Precision
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|