Idea to increase numeric accuracy in newLISP

Started by kinghajj, September 14, 2007, 11:49:39 PM

Previous topic - Next topic

kinghajj

I use a 64-bit Linux distro, so this suggestion might not apply to all versions of newLISP.



I've written a very simple Reverse Polish Notation calculator in C. To store numbers, the data type I chose was "long double." With this, I am able to calculate large numbers such as 2^2048 (*). In newLISP, however, even with a 64-bit build, trying to calculate just 2^1024 returns "inf," and 2^1023 only returns "8.988465674e+307." Is it possible to enable use of "long double" on at least 64-bit builds?



(*) 2^2048 =

32317006071311007300714876688669951960444102669715484032130345427524655138867890

89319720141152291346368871796092189801949411955915049092109508815238644828312063

08773673009960917501977503896521067960576383840675682767922186426197561618380943

38476170470581645852036305042887575891541065808607552399123930385521914333389668

34242068497478656456949485617603532632205807780565933102619270846031415025859286

41771167259436037184618573575983511523016459044036976132332872312271256847108202

09725157101726931323469678542580656697935045997268352998638215525166389437335543

602135433229604645318478604952148193555853611059596230656



And my program happily computes up to 2^16383 (a 4301 digit number); at 2^16384 it returns "inf." I think it's safe to say that 2^16383 is a number that will not practically be needed for some time. In cryptography, however, 2^1024 is a relatively "low" number, so I think newLISP needs to address this issue.

Lutz

#1
Yes, in a future version there will be 'long long' and 'long double' support in the 64-bit version.



For the normal 32-bit version of newLISP there is bignum library support here:



http://newlisp.org/code/modules/gmp.lsp.html">http://newlisp.org/code/modules/gmp.lsp.html



Lutz

cormullion

#2
Is this '64-bit' stuff related to the MacOS X Leopard 10.5 64-bit I sometimes read? This is due for release in October, but I don't think there'll be any problem with existing applications...



I don't have any use for really large numbers yet... My newLISP moon orbit calculations are only estimates anyway - the maths gets too hard long before the floating-point numbers let you down... :)

kinghajj

#3
64-bit OSes are usually near-100% compatible with their 32-bit counterparts. The 64-bit versions of Windows, for example, have a special library that re-implements 32-bit Windows on 64-bit Windows, allowing you to run any 32-bit program. I'm sure that Mac OS X will be no different.



The main advantage with 64-bit processors is more memory and more efficient calculations. 64-bit processors have a theoretical limit of 17,179,869,184 GiB of memory, and because the word length is twice as large as a 32-bit processor's, bigger numbers can be more easily transfered. That makes things like video editing, encryption, etc. faster.



For Macs, I'm surprised a 64-bit version of Mac OS X hasn't been out already, since all current Mac processors since the switch to Intel have been 64-bit.