schemer5rs

R5RS - Display number from operation as decimal


I want to display a number as decimal, however it keeps showing as a fraction

Example

(/ 7 9) ; --> displays as 7/9 but should be .77777

I've tried the builtin #d but it doesn't seem to work on operation results, also number->real and other variations


Solution

  • For this, you can use the exact->inexact procedure:

    (exact->inexact (/ 7 9))
    => 0.77777778