5 ms·
It is worth noting that most scripting languages today are still restricted by 64-bit integers and IEEE floating points limitations. Python and Ruby are probab
by mmoez 7y ago
It is worth noting that most scripting languages today are still restricted by 64-bit integers and IEEE floating points limitations.
Python and Ruby are probably the only popular ones that ship by default with unlimited precision integers.
For arbitrary precision reals in Python, there is mpmath http://mpmath.org/ http://mpmath.org/ . There is also the standard decimal module which "provides support for fast correctly-rounded decimal floating point arithmetic" : https://docs.python.org/3/library/decimal.html https://docs.python.org/3/library/decimal.html
- m4r35n357 7y agoFor MP work in Python, gmpy2 - https://pypi.org/project/gmpy2/ https://pypi.org/project/gmpy2/ comes with a much better selection of MP functions, backed by MPFR, MPC. Also, the buit-in Decimal class is horribly slow by comparison to gmpy2.
- fdej 7y agoAlso (shameless self-promotion) python-flint! http://fredrikj.net/python-flint/ http://fredrikj.net/python-flint/
- baruchel 7y agoPurpose of the Decimal module is not really arbitrary precision computation but rather exact computation on decimal numbers wherever it matters (financial arithmetic, etc.). This module should never be used for scientific purposes.
- 292355744930110 7y agoIn Go "Numeric constants represent exact values of arbitrary precision" https://golang.org/ref/spec#Constants https://golang.org/ref/spec#Constants
- divs1210 7y agoI don't think Go qualifies as a 'scripting language', even though the term is very loosely defined.
- 292355744930110 7y agoI missed the part about scripting languages. Is LISP a scripting language?
- kazinator 7y agoYes. 1. Most Lisp dialects, including Scheme and ANSI Lisp, have interactive modes for evaluating expressions. 2. Most Lisp dialects have a mode of processing files in the same manner: reading individual forms and evaluating them immediately. I.e. it is not necessary to translate files into objects that have to be linked to produce an executable program.
- munificent 7y agoThis is only true for values calculated at compile time. Once the result is stored in a variable it is converted to a fixed-size representation. All runtime calculations and results are fixed size.
- threwawasy1228 7y agoI think Haskell allows for arbitrary-precision with the Integer type. It is limited only by the available memory in the machine.
- divs1210 7y agoEven though the term 'scripting language' is very loosely defined, I don't think Haskell qualifies as one.
- ky3 7y agoHaskell has shell hash-bang scripting capabilities just like Python and Ruby do. See https://stackoverflow.com/questions/8676331/how-to-run-a-haskell-file-in-interpreted-mode/8676377#8676377 https://stackoverflow.com/questions/8676331/how-to-run-a-has...
- kazinator 7y agoAlmost anything can be hash-bang, including C. https://rosettacode.org/wiki/Native_shebang https://rosettacode.org/wiki/Native_shebang https://rosettacode.org/wiki/Multiline_shebang https://rosettacode.org/wiki/Multiline_shebang
- ky3 7y agoTrue, but the difference between C and Haskell hash-bangs is that GHC Haskell provides an interpreter. GCC hash-bang is still an edit-compile-link-debug cycle. Just like with Python and Ruby, Haskell hash-bang accelerates the cycle by jettisoning the compile and linking steps.
- kazinator 7y agoThe Rosetta examples show a solution that only compiles the C file if it has not been previously compiled, or if it has a newer modification timestamp than the executable.
- mpolun 7y agoBigInts are coming to Javascript -- they're supported in most browsers and in node now, but they haven't officially been added to the standard.
- nikofeyn 7y ago> Python and Ruby are probably the only popular ones that ship by default with unlimited precision integers. racket has exact numbers of unlimited size. https://docs.racket-lang.org/reference/numbers.html https://docs.racket-lang.org/reference/numbers.html
- jxy 7y agoIn addition to Scheme and CL, Perl: https://perldoc.perl.org/bignum.html https://perldoc.perl.org/bignum.html Perl6: https://docs.perl6.org/language/math#Arithmetic https://docs.perl6.org/language/math#Arithmetic J: https://code.jsoftware.com/wiki/Vocabulary/xco https://code.jsoftware.com/wiki/Vocabulary/xco ocaml: https://opam.ocaml.org/packages/zarith https://opam.ocaml.org/packages/zarith
- ddragon 7y agoJulia (as a "scripting" language for scientific purposes) also supports them natively, but defaults to normal int/float for performance reasons, which might create some gotchas for people who use the language but are not programmers. https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/#Arbitrary-Precision-Arithmetic-1 https://docs.julialang.org/en/v1/manual/integers-and-floatin... If I remember correctly, Elixir uses arbitrary precision integers by default, though I'm not sure about float.
- hajile 7y agoBigInt works in Firefox, Chrome, Opera, and upcoming Edge at the moment. Safari preview also has at least partial support.