[Tutor] Need more precise digits
Sat, 1 Dec 2001 22:57:23 -0500
On Sat, Dec 01, 2001 at 07:51:01PM -0800, Kirby Urner wrote:
| At 08:45 PM 12/1/2001 -0500, dman wrote:
| >this is one reason that range() doesn't allow float values for start,
| >stop, or increment.
| ... a trap I fell into very recently, with my lazyrange()
| alternative (illustrating the generator feature).
Yep, but you noticed it in time. BTW, did you check the range's
terminating condition with == or >=? Checking equality with floats is
bad because of the approximations that happen. It is unlikely that,
after some arithmatic, a float will exactly equal what you want. It
is better to check if it is equal with some epsilon (that is, close
enough to consider equal). This applies in general, not just to your
Microsoft: "Windows NT 4.0 now has the same user-interface as Windows 95"
Windows 95: "Press CTRL-ALT-DEL to reboot"
Windows NT 4.0: "Press CTRL-ALT-DEL to login"