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

Re: dumb DrScheme rational # question



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.

Hope that helps,
Robby