JRS: In article <11*********************@i40g2000cwc.googlegroups. com>,
dated Mon, 3 Apr 2006 13:28:21 remote, seen in
news:comp.lang.javascript,
CF*******@gmail.com posted :
I was wondering if there is any way to store large numbers in a
variable? With this simple script:
Don't worry about Lahn's ravings; he has psychological problems. A
news-group is for discussion; and if everyone refers only to old
material there will never be any new ideas.
You have found (as reading the newsgroup FAQ and its links would have
told you) that values of type Number gave limited resolution : they are
IEEE Doubles.
Large numbers can be readily stored, in any base from 2 to 64 and
higher, in strings; but they are then hard to manipulate.
Large numbers can be stored as arrays of digits, in any base from 2 up
to 2^53, though 2^26 is the practical limit. One can then write readily
code to process them just as you learned in school, or should have.
I've implemented such a system, for integers, in Pascal/Delphi
(longcalc, via <URL:http://www.merlyn.demon.co.uk/programs.00index.htm>)
- and coded it to calculate pi using the BBP method.
Note that you'll probably get faster running in a language in which code
is compiled and optimised before delivery; you should try representative
code in various language implementations before deciding.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.