Skip to content
Tcl Source Code History Of Ticket 3312466
Login

History Of Ticket 3312466

Artifacts Associated With Ticket 3312466

  1. Ticket change [b2d780dff2] (rid 98413) by vadimosk on 2011-06-06 12:49:43:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OS Ubuntu Linux 10.04 LTS (original repository)
      
      tclsh8.4 - OK
      %expr 9.9 + 9.9 + 9.9
      29.7
      %expr 9.9 * 3
      29.7
      
      tclsh8.5 - BAD
      %expr 9.9 + 9.9 + 9.9
      29.700000000000003
      %expr 9.9 * 3
      29.700000000000003
      
      tclsh8.6 - BAD (package from Debian unstable - tcl8.6_8.6.0~b1-4_amd64)
      %expr 9.9 + 9.9 + 9.9
      29.700000000000003
      %expr 9.9 * 3
      29.700000000000003
      
      
    4. foundin initialized to: "obsolete: 8.6b1"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "vadimosk"
    10. subsystem initialized to: "16. Commands A-H"
    11. title initialized to: "Bad result in expr command"
    12. type initialized to: "Bug"
  2. Ticket change [b51dce90b3] (rid 125186) by dkf on 2011-06-06 21:19:46:

    1. closedate changed to: "2011-06-06T14:19:46"
    2. closer changed to: "dkf"
    3. icomment:
      
      
      allow_comments - 1
      
      9.9 is not representable in a finite number of bits in binary floating point (such as IEEE double precision floats, which Tcl uses under the hood because they've got proper hardware support on virtually all modern hardware) so an approximation is used. That approximation is very slightly larger than the "true value" and causes the difference you see; the "* 3" just makes the error three times larger (though proportionately about the same).
      
      The difference between 8.4 and 8.5 is that 8.5 uses a different floating point number renderer that normally/by-default avoids the worst of the problem (i.e., it uses the shortest decimal representation that will provide the boolean value that we've got internally). Unfortunately, the multiply by 3 has grown the error to the point where it can no longer be hidden this way. Oh well, that's life.
      
      The recommended workaround is to use [format "%.15g" $value] when producing a value for _display_ to users. The rest of the time, perfect fidelity of value (which you get with the current settings, unlike before) is actually more useful. Really.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
    8. username: "dkf"
  3. Ticket change [e0f78e8128] (rid 87363) by dkf on 2011-06-06 21:21:12:

    1. icomment:
      tl;dr: We know. It's deliberate. Use [format] to work around.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"