[plt-scheme] fractions and decimals

From: Paul Schlie (schlie at attbi.com)
Date: Sun Jan 19 19:30:48 EST 2003

Wonder if broadly adopting the convention that decimals terminated with a
zero (0), would be interpreted as an exact number, otherwise considered
inexact, would help unify the two worlds; (little fancier would be to
interpret "..." as an exact repeating input pattern, although not sure how
to reliably convert it into an exact fractional internal representation.

(equal? 0.125  1/8) => #f ; inexact to the specified decimal precision.
(equal? 0.1250 1/8) => #t ; exact to the specified decimal precision.
(equal? 0.3... 1/3) => #t ; exact to the specified decimal precision.

Which could be made consistent with output formatting preferences,
Such that if decimal outputs are specified as being preferred:

0.125 => 0.125  ; inexact to the specified decimal precision.
1/8   => 0.1250 ; exact to the specified decimal precision.
1/3   => 0.3... ; exact to the specified decimal precision.

Or conversely, if fractional output were perfered:

0.125  => 0.125 ; inexact to the specified decimal precision.
0.1250 => 1/8   ; exact to the specified decimal precision.
0.3... => 1/3   ; exact to the specified decimal precision.

(where "..." would be replaced with an over-bar within DrScheme, but
 copied to the clipboard as "...", to enable a successive pastes)

Just thoughts, -paul-



Posted on the users mailing list.