Floating point 'for' loops - value of 0 has significant non
Closed / Invalid218954ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:08:34
OriginalBugID: 3083 Bug
Version: 8.1
SubmitDate: '1999-10-11'
LastModified: '1999-11-11'
Severity: LOW
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: Windows 98
OSVersion: also Linux Redhat 5.0+
Machine: X86
FixedDate: '1999-11-11'
FixedInVersion: 8.2
ClosedDate: '2000-10-25'
Name:
Gail
ReproducibleScript:
% for {set i -0.4} {$i<0.1} {set i [expr $i + 0.10]} {puts $i}
-0.4
-0.3
-0.2
-0.1
-2.77555756156e-017
0.1
ObservedBehavior:
The value of 0 in the 'for' loop has significant non-zero digits. Loops
that test for 0.0 to terminate therefore dont terminate.
Termination is also not correct in the above example, the loop should
stop before outputting 1.0.
Happens on intel processors (Pentium) under Linux and MS windows Tcl.
DesiredBehavior:
No significant non-zero digits after the required number of decimal
places.
This bounds checking was added before 8.2.
-- 11/11/1999 hobbs
welch Closed ticket [218954ffff].
[History diff]2000-10-26 08:32:15
dgp Ticket [218954ffff]: 1 change
[History diff]2001-04-17 10:40:20
dgp Ticket [218954ffff]: 3 changes
[History diff]2001-04-17 10:40:21
dgp Ticket [218954ffff]: 2 changes
[History diff]2001-04-17 10:40:57
Log in (anonymous is fine) to add a comment.