As (hopefully) most of you know, floating point arithmetic is different from real number arithmetic. This is inaccurate for beginners. Many numbers, especially decimal numbers (0,1, 0,3), cannot be represented, which leads to problems such as. A more detailed list can be found here .
Are there public languages that have built-in support for something closer to real-life arithmetic? If not, what good libraries support this?
EDIT: The arbitrary precision of decimaldatatypes is not what I am looking for. I want to be able to represent numbers such as 1/3, sqrt(3)or 1 + 2i.
decimal
1/3
sqrt(3)
1 + 2i
To cover real numbers with any miracle, you will need a symbolic package.
Boost, a C ++ project, has Rational , but this is only part of the story.
(pi, , , Champernowne constant, ). , , - . , e ^ pi, ? ?
Mathematica .
, . . , .
, , , .
, , , , . .
, , - (MATLAB , , ).
, , # - . , ( ) . , , , .
, . -, , ( ) .
, , " ". - , , , ( ) (exp, sin, cos, log ..).
: , , (, , , ). , , , ( ) ( ).
.
, a/b (a/b + ic/d , a/b + sqrt (2) * a/b Q [sqrt (2)] ..). .
, . , , ( , - , , , ) , . Google boost::range gmp .
boost::range
gmp
. Scheme, , , ,
> (+ 1/2 1/3) 5/6 > (* 3 1+1/2i) 3+3/2i > (+ 1/2 .5) 1.0
, algebraic , sqrt(2) - e, , , , Mathematica Maxima.
sqrt(2)
Java: java.math.BigDecimal
java.math.BigDecimal
#: decimal
: Java BigDecimal, Perl Math::BigFloat Math::BigRat, Haskell Integer, wikipedia.
BigDecimal
Math::BigFloat
Math::BigRat
Integer
Ada fixed-point , . , , .
, , IEEE, bignum.
, . (, 1/3). , , , , ββ . (, pi e). , , , , , .
EDIT: , . , 1/3, sqrt (3) 1 + 2i .
Ruby Rational, 1/3 Rational (1,3). Complex.
The scheme defines rational, bonus, floating and complex numbers. Implementation is not required to support them all, but if they are present, you can mix them and they will be "right."
Until it is βbuilt-inβ, I think C ++ (maybe C #) is your best bet. There are classes that have been written for this purpose.
http://www.oonumerics.org/oon/
Source: https://habr.com/ru/post/1765328/More articles:What is wrong with this TextBox style? - wpfUnexpectedly failed git fetch from source - gitHow can I put / paste a Twitpic image? - apiWhy are these UV display coordinates represented in 0-1 and pixels? Shouldn't they use only the 0-1 system? - 3dwhat happens when a javascript array is processed as an object? - javascriptDetecting changes in NSArray in ObjC - objective-cStruts2 JSON plugin with annotations - jsonAre there open source versions of Wavefront OBJ downloaders for the iPhone? - iphonejQuery: onclick Π²ΠΌΠ΅ΡΡΠΎ href= javascript:: - jqueryUsing :; / iframe> with maven assemblies - maven-2All Articles