News for hackers. Stuff that matters.
Re:DEC64: Decimal Floating Point by callesgg on Saturday March 08, 2014 @02:14PM (#7366014)
While i find the binary incomparability with with decimals somewhat annoying.

In the bigger picture what i fell we are generally missing in most programing languages is an EASY way to store and handle fractions.

Re:DEC64: Decimal Floating Point by psquid on Saturday March 08, 2014 @02:33PM (#7366077)
Agreed. Both Haskell and much of the Lisp family support rational numbers, the latter with them automatically being used instead of imprecise results when doing divisions which can't be represented accurately. I miss them a lot when working in other languages.
Re:DEC64: Decimal Floating Point by mistercow on Saturday March 08, 2014 @04:33PM (#7366466)
>In the bigger picture what i fell we are generally missing in most programing languages is an EASY way to store and handle fractions.

I'm squeamish about that. I fear that a lot of new programmers would overuse a fraction type if it were built in, and this can quickly lead to really poor performance.

In most cases, floating point works just fine. Reducing fractions is slow, so you really only want to use them when perfect precision is absolutely necessary.

What I see happening is someone new to programming hits a point where they need a fractional number type. They look in the documentation and they see "integer, floating point, fraction" and they say "Aha! Fraction! I know what those are."

Re:DEC64: Decimal Floating Point by ErsatzVerkehr on Saturday March 08, 2014 @02:33PM (#7366079)
Just curious, what is your use-case in which you need better support for fractions?
Re:DEC64: Decimal Floating Point by callesgg on Saturday March 08, 2014 @02:57PM (#7366175)
A simple example: (i will use decimal instead of binary as it is easier and binary suffers from the same stuff but for other numbers)

(10/3)x(9/4) == 7.5

but due to the fact that computers store the value instead of the fraction it would come out as something like 7.4999999999 cause instead of doing (10x9)/(3x4) it would do 3.3333333333333 x 2.25

Re:DEC64: Decimal Floating Point by giovannibajo1 on Saturday March 08, 2014 @10:57PM (#7367366)
This looks like a case for decimal floating point, not fractionals. In Python:

>>> from decimal import Decimal as D >>> D("10")/D("3") * D("9")/D("4") Decimal('7.50000000000000000000000000')