[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dumb DrScheme rational # question



Lo, on Tuesday, January 29, Robert Bruce Findler did write:

> Quoting Brian Gregor:
> > 
> > DrScheme (v 200alpha9) returns rational #'s for many
> > division operations.  Is there a way to force it to
> > convert to a floating point number?  Common Lisp
> > has a 'float' function for this, but MzScheme doesn't
> > seem to have any such equivalent.
> 
> You can use exact->inexact, or if you start your computations with
> inexact numbers, they will remain inexact when going thru the division
> operations. To write an inexact constant, prefix the numbers with #i,
> like this:
> 
>   #i1.0
> 
> Additionally, if you use functions that return real results (sin, sqrt,
> log, etc) you will get inexact numbers from them.
> 
> But, you should really only be doing that kind of thing if you are
> running into efficiency issues, I'd say.

Well, there is another reason, and this actually came up in 210 labs
from time to time.  Most of the students seemed to think that
2625606.344290554 was more informative as a final answer than
13468902349083467982348905427892890234980624/5129825489023489026890234908253890235.

Maybe it's just me, but I can't say I blame them.

Richard