Tcl Source Code

View Ticket
Login
Ticket UUID: 908375
Title: round() doesn't support numbers larger than 31 bits
Type: Bug Version: obsolete: 8.4.6
Submitter: hemanglavana Created on: 2004-03-02 15:39:49
Subsystem: 47. Bytecode Compiler Assigned To: dkf
Priority: 8 Severity:
Status: Closed Last Modified: 2004-07-04 05:13:29
Resolution: Fixed Closed By: msofer
    Closed on: 2004-07-03 21:36:58
Description:
This was just reported by one of our users today. It
seems that round() doesn't seem to handle numbers
larger than 31 bits:

godel:49> /tmp/hlavana/tcltk/bin/tclsh8.4 
% info patch
8.4.6
% expr round( 2147483647.1 )
2147483647
% expr round( 2147483648.1 )
integer value too large to represent
% expr {2147483648+1}
2147483649
% exit
godel:50> 

If this is a bug, would it be possible to get it fixed
for tcl8.4.6 or is it too late now?
User Comments: msofer added on 2004-07-04 05:13:29:
Logged In: YES 
user_id=148712

Backported.

msofer added on 2004-07-04 04:36:58:
Logged In: YES 
user_id=148712

Fixed in HEAD; should I backport to core-8-4-branch?

dkf added on 2004-07-03 05:13:21:
Logged In: YES 
user_id=79902

I suppose if we restrict ourselves to just producing wides
in the case where we would have failed previously, we'll be
monotonically improving things...

dkf added on 2004-07-03 05:01:37:
Logged In: YES 
user_id=79902

I don't know what answer anyone expects out of round() in
the first place. :/

So long as we have a consistent story, I don't really care.

msofer added on 2004-07-03 04:53:57:

File Added - 92706: wideRound2.patch

Logged In: YES 
user_id=148712

I do not like coercing all results of 'round' to wide;
attached a patch that only does this when necessary. Your
turn :)

dkf added on 2004-05-30 19:36:49:
Logged In: YES 
user_id=79902

Please review this and apply the patch if you think it is
not too semantics-damaging.

hemanglavana added on 2004-03-31 03:07:27:
Logged In: YES 
user_id=81875

The patch seems to work fine:

godel:148> /tmp/hlavana/tcltk/bin/tclsh8.5 
% info patch
8.5a2
% expr round( 2147483648.1 )
2147483648
% expr round( 2147483648.9 )
2147483649
% exit
godel:149> 

I don't see the result of round() as wide to be an issue.

-- thanks

dkf added on 2004-03-30 05:04:12:

File Added - 81829: wideRound.patch

Logged In: YES 
user_id=79902

Try this patch.  The downside is that the result from
round() will normally be a wide now.

hemanglavana added on 2004-03-05 22:23:02:
Logged In: YES 
user_id=81875

The current workaround for this issue is to use the wide()
and add 0.5 to the number for rounding:

hlavana-u5:81> tclsh
% expr wide(2147483648.1)
2147483648
% expr wide(2147483648.9)  
2147483648
% expr wide(2147483648.9+0.5)
2147483649
% expr wide(2147483648.1+0.5)
2147483648
%

dkf added on 2004-03-02 23:40:16:
Logged In: YES 
user_id=79902

It's too late for 8.4.6 as we've already got a release
candidate out for distribution testing (or whatever the
proper term is.)  With any change we'd have to start the
whole release process over again.  Sorry.  :^(  I'll make
this a high prio fix for 8.5a1 though and backport to the
8.4 branch.

Attachments: