When I do (/ 411 125) , I do not get it in terms of decimal. How to do it?
(/ 411 125)
user> (float (/ 411 125)) 3.288 user> (double (/ 411 125)) 3.288
user=> (clojure-version) "1.4.0" user=> (doc quot) ------------------------- clojure.core/quot ([num div]) quot[ient] of dividing numerator by denominator. nil user=> (quot 411 125) 3
As documented , integer division gives rational numbers. Try
(/ 411.0 125)
If you use float for dividends, you will get a decimal answer.
(/ 22.0 7) -> 3.142857142857143
A function is also available (unchecked remainder xy) .
even this will work:
(/ 22. 7) => 3.142857142857143
(float 411/125) is another option if you are given numbers directly, which is the case if you just use REPL as a calculator. Unfortunately, these are a few characters longer than the solution of Jonathan Feinberg and ire_and_curses .;)
(float 411/125)