Back
copy-sign (clj)
(source)function
(copy-sign magnitude sign)
Returns a double with the magnitude of the first argument and the sign of
the second.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#copySign-double-double-
Examples
clojure
(ns clojure.test-clojure.math
(:require
[clojure.test :refer :all]
[clojure.math :as m]))
(deftest test-copy-sign
(is (= 1.0 (m/copy-sign 1.0 42.0)))
(is (= -1.0 (m/copy-sign 1.0 -42.0)))
(is (= -1.0 (m/copy-sign 1.0 ##-Inf))))