Re: [Pharo-project] Unexpected behavior of roundTo:
On Apr 8, 2011, at 7:48 PM, Hilaire Fernandes wrote:
Well, whatever the underneath representation, one can expect roundedTo: 2 to return a float with two decimals.
Sometimes I think we should use the resources that these amazing machines give us these days to move programming languages closer to humans... There are better Float models than the ones that are implemented in hardware. E.g. another INRIA Project is this GNU MPFR: "The MPFR library is a C library for multiple-precision floating-point computations with correct rounding." http://www.mpfr.org/ Why don't we make our language better at "real" math? The power in the machine is definitly there... I am quite convincd that if there are normal programming languages in 50 years, the math part of them will be closer to Mathematica then to C... Marcus -- Marcus Denker -- http://www.marcusdenker.de INRIA Lille -- Nord Europe. Team RMoD.
2011/4/8 Marcus Denker <marcus.denker@inria.fr>:
On Apr 8, 2011, at 7:48 PM, Hilaire Fernandes wrote:
Well, whatever the underneath representation, one can expect roundedTo: 2 to return a float with two decimals.
Sometimes I think we should use the resources that these amazing machines give us these days to move programming languages closer to humans...
There are better Float models than the ones that are implemented in hardware. E.g. another INRIA Project is this GNU MPFR:
"The MPFR library is a C library for multiple-precision floating-point computations with correct rounding."
    http://www.mpfr.org/
Why don't we make our language better at "real" math? The power in the machine is definitly there... I am quite convincd that if there are normal programming languages in 50 years, the math part of them will be closer to Mathematica then to C...
    Marcus
mpfr are still floating point with inexact operations, you just change the precision to whatever number of bits you want. I played with my own modest Smalltalk implementation relying on LargeInteger arithmetic http://www.squeaksource.com/ArbitraryPrecisionFl.html It implements correct rounding to (if correct is round to nearest even). Nicolas
-- Marcus Denker  -- http://www.marcusdenker.de INRIA Lille -- Nord Europe. Team RMoD.
I played with my own modest Smalltalk implementation relying on LargeInteger arithmetic http://www.squeaksource.com/ArbitraryPrecisionFl.html It implements correct rounding to (if correct is round to nearest even).
Nicolas would it be a path for you and us so that we use your library? Ok it will put pressure on you but like that we move one the next age. Stef
At the end of the day, we still insist on expecting there won't be loss of information just because we wrote a decimal print string for a binary floating point number. One can get offended or irritated all one wants, but the reality of the situation won't change. I think the real solution to these "problems" is to implement decimal floating point as per IEEE-754/2008. Then you can write something like 1.2345 and know for a fact the number represented is *exactly* 1.2345. At least one VisualWorks platform already supports decimal floating point in hardware (IBM's POWER line). C99 extensions exist at least in draft form to extend C so that it supports decimal floating point. IBM has released a GPL library in ANSI C that implements the feature. I am not sure what is the deal with the license and if you can e.g.: interface to it without making your whole Smalltalk GPL. Food for thought... On 4/8/11 12:53 , Marcus Denker wrote:
On Apr 8, 2011, at 7:48 PM, Hilaire Fernandes wrote:
Well, whatever the underneath representation, one can expect roundedTo: 2 to return a float with two decimals.
Sometimes I think we should use the resources that these amazing machines give us these days to move programming languages closer to humans...
There are better Float models than the ones that are implemented in hardware. E.g. another INRIA Project is this GNU MPFR:
"The MPFR library is a C library for multiple-precision floating-point computations with correct rounding."
Why don't we make our language better at "real" math? The power in the machine is definitly there... I am quite convincd that if there are normal programming languages in 50 years, the math part of them will be closer to Mathematica then to C...
Marcus
-- Marcus Denker -- http://www.marcusdenker.de INRIA Lille -- Nord Europe. Team RMoD.
participants (4)
-
Andres Valloud -
Marcus Denker -
Nicolas Cellier -
Stéphane Ducasse