Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-09-19
23:31 • Closed ticket [1561260fff]: Problem with big integers plus 7 other changes artifact: 6b3df26771 user: dgp
22:58 • Ticket [1561260fff]: 4 changes artifact: e92ded6e4b user: dgp
22:11 • Ticket [1561260fff]: 4 changes artifact: 44e22f08b0 user: dkf
21:55 • Ticket [1561260fff]: 4 changes artifact: 3f60e9036a user: dgp
07:58 • New ticket [1561260fff]. artifact: 0af29bbe4b user: sarnold75

Problem with big integers

Closed / Fixed1561260fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-09-19 07:58:00
tcl_platform(byteOrder) = littleEndian
tcl_platform(machine)   = intel
tcl_platform(os)        = Windows NT
tcl_platform(osVersion) = 5.1
tcl_platform(platform)  = windows
tcl_platform(threaded)  = 1
tcl_platform(user)      = Stéphane ARNOLD
tcl_platform(wordSize)  = 4

******

I was debugging a math package (in tcllib) named
math::bigfloat.

I figure that 2**exp * 5**exp equals 10**exp.
Not in Tcl 8.5a5! (and 8.5a4 either, I guess)

% expr (2**32)*(5**32)
14058906998405956947534675968

The expected result would be:
% expr (2**32)*(5**32)
100000000000000000000000000000000

It seems that expr 5**32 does not provide
a good result:
% expr 5**32
3273344365508751233

A multiple of five should end with the digit 5,
isn't it?

Strange behavior... I am relying on powers and 
shifts to perform bigfloat computations.
dgpplain2006-09-19 21:55:15
Logged In: YES 
user_id=80530


Confirmed:

% expr 5**27  
7450580596923828125
% expr 5**28
359414837200037393

I'm worried this might be
a problem in libtommath.
Investigating...
dkfplain2006-09-19 22:11:54
Logged In: YES 
user_id=79902

Looks like a problem at the boundary between 64-bit and
arbitrary precision.
dgpplain2006-09-19 22:58:24
Logged In: YES 
user_id=80530

yep, overflow detection is
a complete botch.
dgpplain2006-09-19 23:31:57
Logged In: YES 
user_id=80530


Fixed by removing all the
broken "clever" attempts to
contain these calculations
in native types.  All non-trivial
exponentiation calculations
now done in bignums.
Log in (anonymous is fine) to add a comment.