News for hackers. Stuff that matters.
Re:0.3 - 0.2 == 0.2 - 0.1 is falsy. Which language gets this... by informatimago on Friday October 05, 2012 @11:15AM (#4617214)
Indeed old programming languages get it right:

Fortran (the oldest still in use):

    $ cat sub.f
    C Prints 0.3-0.2 and 0.2-0.3
          PRINT 4, 0.3-0.2, 0.2-0.1
        4 FORMAT ('0.3-0.2=',F3.1,' 0.2-0.1=',F3.1)
          STOP 1
          END
    $ gfortran sub.f -o sub
    $ ./sub
    0.3-0.2=0.1 0.2-0.1=0.1
    STOP 1
    $ 
Lisp (the second oldest still in use):

    cl-user> (values (- 3/10 2/10) (- 2/10 1/10))
    1/10
    1/10
Cobol (the third oldest still in use):

    $ cat sub.cob
           IDENTIFICATION DIVISION.
           PROGRAM-ID. DIFFERENCE.
           ENVIRONMENT DIVISION.
           INPUT-OUTPUT SECTION.
           FILE-CONTROL.
           DATA DIVISION.
           FILE SECTION.
           WORKING-STORAGE SECTION.
           77 out32 pic 9.9.
           77 out21 pic 9.9.
           PROCEDURE DIVISION.
               subtract 0.2 from 0.3 giving out32.
               subtract 0.1 from 0.2 giving out21.
               display '; 0.3 - 0.2 = ' out32 .
               display '; 0.2 - 0.1 = ' out21 .
               goback.

    $ cobc  -fixed -Wcolumn-overflow -Wparentheses  -x sub.cob
    $ ./sub
    ; 0.3 - 0.2 = 0.1
    ; 0.2 - 0.1 = 0.1
    $
Re:0.3 - 0.2 == 0.2 - 0.1 is falsy. Which language gets this... by zerohp on Thursday October 11, 2012 @06:57PM (#4643192)
These code samples don't test equality. Printing the output probably rounds off the difference.