Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2010-02-02
04:24 • Ticket [2941443fff] expr 9999999**9999999 kills my progs status still Closed... artifact: ac45a799a0 user: ferrieux
01:45 • Ticket [2941443fff]: 4 changes artifact: 5d91bc8eef user: dgp
2010-01-28
17:14 • Ticket [2941443fff]: 4 changes artifact: 9a759fd4bc user: ferrieux
16:11 • Ticket [2941443fff]: 4 changes artifact: 7344212802 user: anonymous
16:01 • Ticket [2941443fff]: 4 changes artifact: 105ee9094d user: ferrieux
16:00 • Closed ticket [2941443fff]. artifact: 3512917260 user: ferrieux
14:41 • Ticket [2941443fff]: 2 changes artifact: 6b3408bdbc user: dkf
06:59 • New ticket [2941443fff]. artifact: def54f83f7 user: anonymous

expr 9999999**9999999 kills my progs

Closed / Invalid2941443fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2010-01-28 06:59:41
expr 9999999**9999999
and tclsh/eggdrop hangs. :(

But with pow is ok
% expr pow(9999999,9999999)
Inf

On 8.6b1.1 works too.
dkf Ticket [2941443fff]: 2 changes [History diff]2010-01-28 14:41:22
ferrieuxplain2010-01-28 16:00:06
As stated in  expr.n,  integer operations are done in arbitrary precision (no overflow).
This is the case of ** when both operands are integer.

So Tcl is not hanging, it is just computing a very large number. You can verify that by monitoring the process's CPU (100%) and memory consumption (increasing regularly). Of course at some point it may exhaust your system's resources, but we can hardly blame Tcl for the hardware not being a true Turing bandwidth with infinite tape ;-)

Hence closing as Invalid.
ferrieuxplain2010-01-28 16:01:42
Heh, read "true Turing _machine_". So much for focus-follows-mouse ;-)
plain2010-01-28 16:11:35
M... I think so. But if tcl can't calculate this expression for a whole day (and more, we test it more than 24 hours in different computers) it is a bug, IMHO. :)
ferrieuxplain2010-01-28 17:14:24
allow_comments - 1

Nonsense. Some algorithms take time, period. If a computation requires a month of CPU and a terabyte of RAM on a helium-cooled supercomputer, giving it to your 3GHz desktop PC with 4G of RAM (and a terabyte of swap ;-) will take generations.

Not a bug.
dgpplain2010-02-02 01:45:59
Patience, grasshopper.

% time {expr {9999999**9999999}} 1
466843906 microseconds per iteration

Not even 10 minutes.
ferrieuxplain2010-02-02 04:24:35
Yeah, though converting it to decimal for display may take a while ;-)
Log in (anonymous is fine) to add a comment.