When I divide numbers in clojure I get a fraction , how do I get the decimal?

Solution 1:

user> (float (/ 411 125))
3.288
user> (double (/ 411 125))
3.288

Solution 2:

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

Solution 3:

As documented, integer division yields rational numbers. Try

(/ 411.0 125)

Solution 4:

If you use a float for the dividend, you'll get a decimal answer.

(/ 22.0 7) -> 3.142857142857143

There's also the (unchecked-remainder x y) function available.

Solution 5:

even this will work:

(/ 22. 7) => 3.142857142857143