[racket] 80-bit precision in Racket

From: Greg Hendershott (greghendershott at gmail.com)
Date: Wed Nov 14 19:54:30 EST 2012

> My understanding of Scheme, including Racket, is that types get converted
> automatically without explicit casting. This is not an add-on for the
> language, but is inherent in the language. For example:
> (/ 10 6)
> 5/3           this is what Gambit does
> (/ 10 6)
> 1 2/3        this is what Racket does
> (/ 10 6)
> 1.66667   this is what SICP says will happen (pg 5)
>
> Here we have integer data types as inputs, and either a rational or a float
> as output. This is what I mean by dynamic-OOP, and what I think is
> inappropriate for a numerical program such as yours. It is pretty convenient
> for scripting, in which case the user just thinks "number" without
> distinction between integers, rationals or floats --- most casual
> programmers don't consider such distinctions to be important, as high-school
> algebra class never made any such distinction. These are important
> distinctions for numerical programmers however.

In addition to:

  > (/ 10 6)
  1 2/3

  > 10/6
  1 2/3

See also:

  > (/ 10.0 6.0)
  1.6666666666666667

  > (exact->inexact 10/6)
  1.6666666666666667

  > #i1
  1.0

  > #i10/6
  1.6666666666666667

And so on.

Also see racket/flonum

Posted on the users mailing list.