error in expr
Closed / Fixed218430ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:57:31
OriginalBugID: 6011 Bug Version: 8.3.1 SubmitDate: '2000-07-14' LastModified: '2000-07-17' Severity: SER Status: Closed Submitter: techsupp ChangedBy: ericm OS: All OSVersion: AIX Mac WIn98 SuSE Linux 6.4 FixedDate: '2000-10-25' ClosedDate: '2000-07-17' Name: Alexander Schoepe CustomShell: no ReproducibleScript: expr int(19.49 * 100) % 10 DesiredBehavior: result should be 9 but expr returns with 8 As has been discussed on comp.lang.tcl, this is really a "feature" of how floating-point numbers are represented on a particular platform. As Don Porter said: The Jedi seeks not exact results from floating point operations. % expr int(19.49 * 100) % 10 8 % expr int(19.49 * 100) 1948 % expr 19.49 * 100 1949.0 % set tcl_precision 17 17 % expr 19.49 * 100 1948.9999999999998 Every programmer eventually learns this lesson, but it's not a bug, nor a difficulty specific to Tcl. --- Eric Melski The Other Tcl Guy ericm at ajubasolutions.com Ajuba Solutions -- 07/17/2000 ericm
welch Closed ticket [218430ffff].
[History diff]2000-10-26 08:22:15
dgp Ticket [218430ffff]: 3 changes
[History diff]2001-04-20 02:29:13
Log in (anonymous is fine) to add a comment.