Float
In Sidef, all literal numbers are specially parsed and converted implicitly into a rational number, which are internally represented by Math::GMPz and Math::GMPq.
This means that Sidef, by default, does not suffer from the floating-point inaccuracy:
An integer or a rational number can be converted to a floating-point value by using the .float
Number method, which represents floating-points using Math::MPFR (which is the Perl interface to the MPFR library) at a default precision of 192 bits:
In numerical operations, a floating-point number will automatically propagate:
The precision of floating-point numbers can be changed by modifying the Num!PREC
class-variable:
By using the local
keyword, the precision will be changed only locally (which also includes any function/method call in the current scope):
Last updated