Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7309fa5240837ff7810884a838ae802e991c4738
Ticket: 2954959fffffffffffffffffffffffffffffffff
expr abs(0.0) is -0.0
User & Date: nijtmans on 2010-02-22 17:45:35
Changes

  1. foundin changed to: "obsolete: 8.5.8"
  2. icomment:
    Added some more tests, just to prove that the TCL_NUMBER_LONG was not quite right either. The problem
    is that in ieee floating point math, -0.0 == 0.0 gives true! This means that you cannot really distinguish
    -0.0 and 0.0 in floating point math.
    
    Looking at the test cases, the rule seems to be:
    - If the input looks negative, take the negative of the output and take that as a result.
    - otherwise, take the unchanged input.
    
    No, what looks negative? For example, -0.0 and -0 look negative, but really are
    not: they are both forms of zero! Still, we want to output resp. 0.0 and 0 in those
    cases. So, we need to distinguish between -0.0 and 0.0 (in the float case) and
    between 0 and -0 (in the long case). How do we do that.
    
    In the float case, we can use memcmp(). In the long case, I see no other way to look
    for ´-´ characters (if there is a string representation). Anyway, this way I could
    make all test cases pass.
    
    For 8.4 the story is a little bit different. The only 'mistake' was that abs(-0.0) returns
    -0.0, which is in fact correct, but not expected regarding the above rules. Numbers
    like 1e-324 result in an underflow immediately in 8.4, it seems not worth to
    fix that. But the abs(-0.0) case still can be fixed, therefore leaving this issue open.
    
    
  3. login: "nijtmans"
  4. mimetype: "text/plain"
  5. username: "nijtmans"