How do I get mit-scheme to return a floating point number?
-
06-07-2019 - |
Question
(/ 4 3) returns 4/3 as an answer. What is the simplest way to get 1.3...?
Solution
An easy way would be to make sure that one of the numbers in the calculation is already a floating-point number:
> (/ 4.0 3)
1.3333333333333333
Another way would be to use exact->inexact
:
> (exact->inexact (/ 4 3))
1.3333333333333333
OTHER TIPS
use
(/ 4 3.0)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow