Back
scalb (clj)
(source)function
(scalb d scaleFactor)
Returns d * 2^scaleFactor, scaling by a factor of 2. If the exponent
is between Double/MIN_EXPONENT and Double/MAX_EXPONENT, the answer is exact.
If d is ##NaN => ##NaN
If d is ##Inf or ##-Inf => ##Inf or ##-Inf respectively
If d is zero => zero of same sign as d
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#nextDown-double-
Examples
clojure
(ns clojure.test-clojure.math
(:require
[clojure.test :refer :all]
[clojure.math :as m]))
(deftest test-scalb
(is (NaN? (m/scalb ##NaN 1)))
(is (= ##Inf (m/scalb ##Inf 1)))
(is (= ##-Inf (m/scalb ##-Inf 1)))
(is (pos-zero? (m/scalb 0.0 2)))
(is (neg-zero? (m/scalb -0.0 2)))
(is (= 32.0 (m/scalb 2.0 4))))