Back

get-exponent (clj)

(source)

function

(get-exponent d)
Returns the exponent of d. If d is ##NaN, ##Inf, ##-Inf => Double/MAX_EXPONENT + 1 If d is zero or subnormal => Double/MIN_EXPONENT - 1 See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#getExponent-double-

Examples

clojure
(ns clojure.test-clojure.math
  (:require
    [clojure.test :refer :all]
    [clojure.math :as m]))

(deftest test-get-exponent
  (is (= (inc Double/MAX_EXPONENT) (m/get-exponent ##NaN)))
  (is (= (inc Double/MAX_EXPONENT) (m/get-exponent ##Inf)))
  (is (= (inc Double/MAX_EXPONENT) (m/get-exponent ##-Inf)))
  (is (= (dec Double/MIN_EXPONENT) (m/get-exponent 0.0)))
  (is (= 0 (m/get-exponent 1.0)))
  (is (= 13 (m/get-exponent 12345.678))))