[plt-scheme] fractions and decimals

From: Paul Schlie (schlie at attbi.com)
Date: Sun Jan 19 21:00:23 EST 2003

Wonder if broadly adopting the convention that decimals terminated with a
zero (0), would be interpreted as an inexact number, otherwise considered
exact; 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.

1      == 1      ; exact
1.0    == 1.0    ; inexact

0.125  == 1/8    ; exact
0.1250 == 0.1250 ; inexact

0.3..  == 1/3    ; exact
0.33   == 33/100 ; exact
0.3330 == 0.3330 ; inexact

Such if decimal outputs are specified as being preferred:

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

1/3    => 0.3..  ; exact to the specified decimal precision.
0.33   => 0.33   ; exact to the specified decimal precision.
0.3330 => 0.3330 ; inexact to the specified decimal precision.

Or if fractional output were specified as being preferred:

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

1/3    => 1/3    ; exact to the specified decimal precision.
0.3..  => 1/3    ; exact to the specified decimal precision.
0.33   => 33/100 ; exact to the specified decimal precision.
0.3330 => 0.3330 ; inexact 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)

Which overall seems reasonably nice and simple,

-paul-



Posted on the users mailing list.