Fork me on GitHub
#beginners
<
2015-07-11
>
charliegriefer04:07:12

Hey all. Got a function that has the following line in it: (if (> clicks 0) (* 100 (float (/ total-earnings clicks))) 0). In a situation where clicks is 12 and total-earnings is 10, running the function in CIDER gives me a Non-terminating decimal expansion; no exact representable decimal result. error. Yet, if I just run (* 100 (float (/ 10 12))) in the REPL, I get 83.33333134651184.

charliegriefer04:07:19

Probably doing something incredibly naive… but I can’t figure out why running the entire function fails with the non-terminating decimal expansion error

teslanick13:07:22

I would assume the difference has something to do with the REPL lowering the precision level

teslanick13:07:29

You can use the with-precision function to work around the issue: (* 100 (with-precision 5 (/ total-earnings clicks)))