You're viewing version 1.2.0 of rationalize. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

rationalize

clojure.core

  • (rationalize num)
returns the rational value of num

2 Examples top

  • user=> (rationalize 1.5)
    3/2
    
  • user=> (rationalize Math/PI)
    3141592653589793/1000000000000000
    
    user=> (rationalize (Math/sqrt 2))
    14142135623730951/10000000000000000
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:1016 top

(defn rationalize
  "returns the rational value of num"
  {:added "1.0"}
  [num]
  (. clojure.lang.Numbers (rationalize num)))
Vars in clojure.core/rationalize: defn num
Used in 0 other vars

Comments top

No comments for rationalize. Log in to add a comment.