cljs.math/get-exponent
function | since v1.11.50 | Edit |
(get-exponent d)
Source docstring:
Returns the exponent of d.
If d is ##NaN, ##Inf, ##-Inf => max_Float64_exponent + 1
If d is zero or subnormal => min_Float64_exponent - 1
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#getExponent-double-
(defn ^number get-exponent
{:added "1.11.10"}
[d]
(cond
(or ^boolean (js/isNaN d) (not ^boolean (js/isFinite d))) (inc EXP-MAX)
(zero? d) (dec EXP-MIN)
:default (let [a (js/ArrayBuffer. 8)
f (js/Float64Array. a)
i (js/Uint32Array. a)
hi (if little-endian? 1 0)]
(aset f 0 d)
(- (bit-shift-right (bit-and (aget i hi) EXP-BITMASK32) (dec SIGNIFICAND-WIDTH32)) EXP-BIAS))))