Tk Library Source Code

View Ticket
Login
Ticket UUID: 3141584
Title: units::convert bug (when value is zero)
Type: Patch Version: None
Submitter: yyamasak Created on: 2010-12-22 09:13:33
Subsystem: units Assigned To: techentin
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2010-12-22 22:17:01
Resolution: Fixed Closed By: techentin
    Closed on: 2010-12-22 15:17:01
Description:
tcllib version 1.1.2

If 0 is specified as source value, units::convert regards it as (blank value + source units). As a result, it returns 1.0 * scale.

For example,
::units::convert 0.0cm cm; #=> 0.0 (Correct!)
::units::convert 0cm cm; #=> 1.0 (Wrong! The same result as ::units::convert cm cm)
::units::convert 0cm mm; #=> 10.0 (Wrong! The same result as ::units::convert cm mm)
User Comments: techentin added on 2010-12-22 22:17:01:

allow_comments - 1

techentin added on 2010-12-22 22:17:00:
Good call.  I implemented a fix a little differently from the patch, by moving the floating point conversion (and octal leading zero issue) into units::reduce.

yyamasak added on 2010-12-22 16:13:33:

File Added - 396694: units.tcl.patch

Attachments: