Tcl Source Code

View Ticket
Login
Ticket UUID: 2002328
Title: format cmd differs from ANSI sprintf in rounding
Type: Bug Created on: 2008-06-25 09:31:29
Submitter: nobody Assigned to: davidw
Subsystem: 75. Tutorial Severity:
Priority: 5 Medium Last modified: 2008-07-18 09:20:36
Status: Closed Closed by: sf-robot
Resolution: Invalid Closed on: 2008-07-18 02:20:36
Version: obsolete: 8.4.19
Description:
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".
User Comments:
[email protected] added on 2008-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_benny added on 2008-06-25 21:51:24:
Logged In: YES 
user_id=143885
Originator: NO

Sorry, forgot to login, the previous comment was from me.

sf-robot added on 2008-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).