Skip to content
Tcl Source Code View Ticket
Login

View Ticket

expr {7244019458077122840 << 1}

Closed / Fixed920e39363459606aa1a1776fcde35e968f497ab5Created 3 years agoUpdated 3 years ago
Descriptionplain2023-08-25 13:57:59
With [73da5acb07c] on 64-bit linux

expr {7244019458077122840 << 1}

returns 14488038916154245680 to me.

With same version on 64-bit Windows (mingw-build) it

retuns -3958705157555305936 to me.

On the same windows 10 box, build with the sam tool chain
8.6.13 agrees with the result on linux.
Referenced by2
apnadkarnimarkdown2023-08-25 16:41:02

Just to add a bit more information, the breakage is when the result exceeds TCL_WIDE_MAX.

% expr {0x3fffffffffffffff << 1}
9223372036854775806
% expr {0x4000000000000000 << 1}
-9223372036854775808
jan.nijtmanswiki2023-08-25 21:06:49

Didn't try it on 32-bit hardware yet, but I'm quite sure that the "1UL" here was the real problem.

Commit: [2ed2ec021b6959ee]

Thanks!

jan.nijtmans Pending ticket [920e393634]. [History diff]2023-08-25 21:07:48
jan.nijtmans Closed ticket [920e393634]. [History diff]2023-09-12 12:28:23
Log in (anonymous is fine) to add a comment.