How to get mit circuit to return floating point number?

(/ 4 3) returns 4/3 as the answer. What is the easiest way to get 1.3 ...?

+6
scheme
source share
2 answers

A simple 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 
+16
source share

using

 (/ 4 3.0) 
+4
source share

All Articles