[racket] Question about round

From: Jos Koot (jos.koot at telefonica.net)
Date: Fri Sep 30 17:42:52 EDT 2011

I already wrote:
#lang racket
(= (inexact->exact (round (/ 1.0 1.1e-200)))
 (round (/ #e1.0 #e1.1e-200))) ; -> #f
A computation that ends up with an integer may introduce a computational
error when during the computation inexact numbers have been used.
Inexactness should remain contaguous.
I do admit that (min 0 +inf.0) can retuirn an exact integer.


From: users-bounces at racket-lang.org [mailto:users-bounces at racket-lang.org]
On Behalf Of Mark Engelberg
Sent: viernes, 30 de septiembre de 2011 18:18
To: Stephen Bloch
Cc: users at racket-lang.org
Subject: Re: [racket] Question about round

I'm amazed at how long I've gone with the misconception that:
Exact Numbers = Integers union Rationals
Inexact Numbers = Floating Point numbers
(Frankly, I never really thought much about what infinities were.  I assumed
they were a separate, distinct type).

When I saw in the docs for round that it returns an integer, and I was
getting an inexact number, I was sure it was a mistake.  Thanks for helping
me straighten out my thinking on this.  I can see how you might want to test
an inexaxct number for whether it is the floating point approximation of an
"integer", so that makes sense.  Still seems weird and inconvenient for
round to give you back an inexact integer rather than an exact one, but I
can see now how this behavior matches the standard.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110930/72eb768c/attachment.html>

Posted on the users mailing list.