Tcl Source Code

View Ticket
Login
Ticket UUID: 2798543
Title: bogus bignum exponent calculations
Type: Bug Created on: 2009-05-29 18:53:19
Submitter: dgp Assigned to: dgp
Subsystem: 47. Bytecode Compiler Severity:
Priority: 5 Medium Last modified: 2009-06-03 00:58:29
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2009-06-02 17:58:29
Version: obsolete: 8.5.7
Description:
% string length [expr {10**2**15}]
32769
% string length [expr {10**2**16}]
17
% expr {10**2**16}
21936950640377856
User Comments:
dgp added on 2009-05-30 02:25:15:
Simpler demo:

% expr {10**65536}
21936950640377856

Something in the logic that chooses
among the many (!!) implementations of
exponent computation is borked.

dgp added on 2009-05-30 02:35:02:
Something wrong computing the value
of "base" at line 5963?  Computation is
done in a short int, but what happens
when l2 is so big that we're overflowing
that?

dgp added on 2009-05-30 04:36:32:
More ugliness:

% expr {10**65553 == 10**17}
1

andreas_kupries added on 2009-05-30 04:54:11:
Curiosity: Is that ugliness all in Tcl's use of libtommath, or in libtommath itself ?

dgp added on 2009-05-30 22:01:16:
Neither.  All appearances say it's
in TEBC's own "optimized table lookup"
implementation.

andreas_kupries added on 2009-06-01 22:39:01:
Ok. The optimized table lookup is Kevin's work, IIRC.

dgp added on 2009-06-01 23:55:03:
Similar trouble in the 32 bit
table lookup:

% expr {7**9 == 7**65545}
1

dgp added on 2009-06-02 04:35:54:
tests committed demonstrating broken cases

dgp added on 2009-06-03 00:58:29:

allow_comments - 1


Fixes committed.