Floating point errors in the Julia Language

Поділитися
Вставка

КОМЕНТАРІ • 18

  • @frankelliott244
    @frankelliott244 2 місяці тому +4

    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.

    • @AbelSiqueira
      @AbelSiqueira  2 місяці тому

      Thanks. Do you think the video convey that info well?

  • @SAC.489
    @SAC.489 3 місяці тому +3

    This problem is in every programming language

    • @AbelSiqueira
      @AbelSiqueira  3 місяці тому

      Do you think the video made it clear?

    • @oterotube13
      @oterotube13 3 місяці тому +1

      The title is misleading, isn't it. ?

  • @MisterDan
    @MisterDan Місяць тому

    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!

    • @AbelSiqueira
      @AbelSiqueira  25 днів тому +2

      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.

    • @MisterDan
      @MisterDan 25 днів тому

      @@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.

  • @DrunkenUFOPilot
    @DrunkenUFOPilot Місяць тому

    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.

    • @AbelSiqueira
      @AbelSiqueira  Місяць тому +1

      Thanks for sharing some code @DrunkenUFOPilot. Indeed I could have made that clearer in the end. Thanks for watching.

  • @haltsimog
    @haltsimog Рік тому

    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!

    • @AbelSiqueira
      @AbelSiqueira  Рік тому

      Thanks, Raul. Interesting problem. Can you also give an example?

  • @gaislurons
    @gaislurons Рік тому +1

    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
      @AbelSiqueira  Рік тому

      Hi Jorge, thanks for the input. What about a scientific calculator? I don't have one easily available.

    • @gaislurons
      @gaislurons Рік тому +1

      @@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 ;-)

    • @AbelSiqueira
      @AbelSiqueira  Рік тому

      That's true. But I think that's where things like the Decimal floating point that I mentioned comes in. What do you think?

  • @eliascarvalho8637
    @eliascarvalho8637 Рік тому

    Amazing video as always!