Skip to content
Tcl Source Code View Ticket
Login

View Ticket

format cmd differs from ANSI sprintf in rounding

Closed / Invalid2002328fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-06-25 09:31:29
The manual page for the format command lists the differences from the ANSI sprintf function:
http://www.tcl.tk/man/tcl/TclCmd/format.htm#M22

This list doesn't tell that the Tcl format command does rounding, which is quite a difference:
[format "%.0f" 1.9] returns "2", while
sprintf("%.0f", 1.9) returns "1".
[email protected]plain2008-06-25 21:50:04
Logged In: NO 

> sprintf("%.0f", 1.9) returns "1".

That would be a bug in the C library.  The C language
specifies that sprintf does rounding here.
cc_bennyplain2008-06-25 21:51:24
Logged In: YES 
user_id=143885
Originator: NO

Sorry, forgot to login, the previous comment was from me.
dgp Pending ticket [2002328fff]. [History diff]2008-07-03 23:36:21
sf-robotplain2008-07-18 09:20:36
Logged In: YES 
user_id=1312539
Originator: NO

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.