this is not a feature of the language. It’s a feature of the floating point representation. Numerical analysts know how to count for this. In fact, the accuracy of algorithms is frequently stated in terms of machine epsilon., the smallest number you can add to one so that the result is not equal to one.
We fixed this in the sheer power language by creating a new data type called REAL, where the integer part of numbers is stored in one memory location and the fractional part in another. It was a hassle to make it efficient, but it was worth it for business applications. Nice video!
We use Rational frequently when we want to deal with exact numbers. For decimal floating point numbers, I think people like to use Decimals.jl or maybe some newer package. How does Sheer compares with Julia? Thanks for watching.
@@AbelSiqueira Sheerpower does very well -- speed wise, because it just does two integer operation for most math. The exception being division.. which can be slow if we can't short-cut it.
The easiest semi-mindless workaround for those who want to see exact results, for this kind of example, may be to use rationals. For example, replace 0.2 with 2//10. So compute: 1//10 + 2//10 - 3//10 and an exact zero will result.
I recently came across about a problem about a little boy who had to do divisions for his math homework, but he hated repeating decimals. So you had to choose a base B, given a series of pairs of integers (nominator, denominator), such that when you did the division in each pair in the base B it wouldn't be a repeating decimal. Pretty interesting problem that might help newcomers gain insight into what's going on here!
Use gnome-calculator (or maybe another simple desktop calculator). 0,1+0,2-0,3= 0 ... (even with 100 for decimals number). The title should be "Julia is not better than simple desktop calculator". In fact, this is not really a "computing" problem. It's a human-computer interface problem...
@@AbelSiqueira It depends. Some are ok others are not (you choose what is ok for you ;-) The point is that IT'S POSSIBLE to have a correct behavior regarding human expectation (and not only IEEE rules). Think about C index array starting at 0 vs Julia starting at 1 (if i'm not wrong). I was stunned to discover this classical "problem" only at university level, because in the previous years I only used [scientific] calculators (Texas Instrument, during the 80s ;-)
this is not a feature of the language. It’s a feature of the floating point representation. Numerical analysts know how to count for this. In fact, the accuracy of algorithms is frequently stated in terms of machine epsilon., the smallest number you can add to one so that the result is not equal to one.
Thanks. Do you think the video convey that info well?
This problem is in every programming language
Do you think the video made it clear?
The title is misleading, isn't it. ?
We fixed this in the sheer power language by creating a new data type called REAL, where the integer part of numbers is stored in one memory location and the fractional part in another. It was a hassle to make it efficient, but it was worth it for business applications. Nice video!
We use Rational frequently when we want to deal with exact numbers. For decimal floating point numbers, I think people like to use Decimals.jl or maybe some newer package. How does Sheer compares with Julia? Thanks for watching.
@@AbelSiqueira Sheerpower does very well -- speed wise, because it just does two integer operation for most math. The exception being division.. which can be slow if we can't short-cut it.
The easiest semi-mindless workaround for those who want to see exact results, for this kind of example, may be to use rationals. For example, replace 0.2 with 2//10.
So compute:
1//10 + 2//10 - 3//10
and an exact zero will result.
Thanks for sharing some code @DrunkenUFOPilot. Indeed I could have made that clearer in the end. Thanks for watching.
I recently came across about a problem about a little boy who had to do divisions for his math homework, but he hated repeating decimals. So you had to choose a base B, given a series of pairs of integers (nominator, denominator), such that when you did the division in each pair in the base B it wouldn't be a repeating decimal.
Pretty interesting problem that might help newcomers gain insight into what's going on here!
Thanks, Raul. Interesting problem. Can you also give an example?
Use gnome-calculator (or maybe another simple desktop calculator). 0,1+0,2-0,3= 0 ... (even with 100 for decimals number). The title should be "Julia is not better than simple desktop calculator". In fact, this is not really a "computing" problem. It's a human-computer interface problem...
Hi Jorge, thanks for the input. What about a scientific calculator? I don't have one easily available.
@@AbelSiqueira It depends. Some are ok others are not (you choose what is ok for you ;-) The point is that IT'S POSSIBLE to have a correct behavior regarding human expectation (and not only IEEE rules). Think about C index array starting at 0 vs Julia starting at 1 (if i'm not wrong). I was stunned to discover this classical "problem" only at university level, because in the previous years I only used [scientific] calculators (Texas Instrument, during the 80s ;-)
That's true. But I think that's where things like the Decimal floating point that I mentioned comes in. What do you think?
Amazing video as always!
Thanks, Elias!