I don't think that's necessarily true. Intervals work fine with non-integer start, stop, and increment values - but if you're using Floats you must beware of roundoff errors. Try inspecting
(0.1 to: 1.0 by: 0.1) asOrderedCollection
and view the results. The values appear correct - but if you evaluate
((0.1 to: 1.0 by: 0.1) asOrderedCollection at: 9) - 0.9
you get -1.110223024625156e-16, indicating that some roundoff error has begun to creep in.
Floats suck.
Bob Jarvis The Timken Company
-----Original Message----- From: Peter Smet [SMTP:peter.smet@flinders.edu.au] Sent: Friday, July 30, 1999 2:40 AM To: squeak@cs.uiuc.edu Subject: Re: [bug] my first squeak bugfix - Interval>>includes:
Sorry,
I just looked at the Interval creation method, and see that increment must be an Integer. Ignore my previous posts (blush)(although it would be nice if intervals could have smaller steps)..
Peter
Bob Jarvis wrote:
Floats suck.
ScaledDecimals rule!
Try my Squeak implementation of ScaledDecimal (intended to be ANSI compliant). The most recent changeset is available from ftp://ftp.wellthot.com/pub/squeak/goodies/ScaledDecimal/.
After filing in the ScaledDecimal support and Alan Lovejoy's Inteval>includes: fix, you can the evaluate the following expressions and Be Unsurprised(TM) with Squeak:
(((1.3s to: 2.2s by: 0.3s) collect: [:i | i]) at: 3) = 1.9s true (1.0s to: 5.0s by: 1.0s) includes: 1.4s false (1.3s to: 2.2s by: 0.3s) includes: 1.9s true (1.0s to: 5.0s by: 0.2s) includes: 1.2s true (1.0s to: 5.0s by: 0.3s) includes: 1.3s true ((0.1s to: 1.0s by: 0.1s) asOrderedCollection at: 9) - 0.9s 0.0s
-Mark Schwenk WellThot Inc.
squeak-dev@lists.squeakfoundation.org