Menu

#3880 expr returns incorrect results on M68K architecture

obsolete: 8.5b3
closed-invalid
8
2007-12-20
2007-12-15
No

Hi!

expr in current HEAD returns the following on Motorola M68K architecture:

% expr 0.1
0.000
% expr 1e-10
0e-12

The bug is triggered only when the final result is shown, and only when the resulting number is less than one in absolute value. Then expr replaces mantissa by zero.

% expr (1.0/10)
0.000
% expr (1.0/10)*10
1.0

Also, expr.test fails with the following:
expr.test
Test file error: unable to alloc 3988184000 bytes

(I don't know if it's the same bug or another one).

8.4.16 works fine and passes all the tests.

Discussion

  • Don Porter

    Don Porter - 2007-12-18
    • labels: --> 47. Bytecode Compiler
    • milestone: --> obsolete: 8.5b3
    • priority: 5 --> 8
    • assigned_to: nobody --> msofer
     
  • Don Porter

    Don Porter - 2007-12-18

    Logged In: YES
    user_id=80530
    Originator: NO

    Is this another symptom of 1851832?

     
  • Nobody/Anonymous

    Logged In: NO

    Even if it's a symptom of 1851832 the current HEAD (with a patch from 1851832) doesn't cure it.

     
  • miguel sofer

    miguel sofer - 2007-12-18

    Logged In: YES
    user_id=148712
    Originator: NO

    I think Tcl_Objs are properly aligned, my guess is that the problem is in TclDoubleDigits(). I will not be able to look at this in the next few days.

    Please report more platform details - is this linux? What libc?

     
  • Sergei Golovan

    Sergei Golovan - 2007-12-18

    Logged In: YES
    user_id=410366
    Originator: YES

    Yes, it's Debian Linux, glibc version is 2.5.

     
  • Don Porter

    Don Porter - 2007-12-18

    Logged In: YES
    user_id=80530
    Originator: NO

    Wonder if this is an issue
    analogous to what we faced
    with the Nokia 770? Yet
    another wacky endian variation?

    http://wiki.tcl.tk/15408

     
  • Sergei Golovan

    Sergei Golovan - 2007-12-20

    Logged In: YES
    user_id=410366
    Originator: YES

    It's a bug in frexp() function. The following program:

    #include <math.h>
    #include <stdio.h>

    main() {
    double v;
    int e;
    v = frexp(1.1, &e);
    printf("%g, %d\n", v, e);
    v = frexp(0.1, &e);
    printf("%g, %d\n", v, e);
    }

    prints out
    0.55, 1
    0.05, -2147483647

    which is obviously wrong. The result should be
    0.55, 1
    0.8, -3

    So, there's no bug in Tcl itself.

     
  • miguel sofer

    miguel sofer - 2007-12-20
    • status: open --> closed-invalid