Back

next-after (clj)

(source)

function

(next-after start direction)
Returns the adjacent floating point number to start in the direction of the second argument. If the arguments are equal, the second is returned. If either arg is #NaN => #NaN If both arguments are signed zeros => direction If start is +-Double/MIN_VALUE and direction would cause a smaller magnitude => zero with sign matching start If start is ##Inf or ##-Inf and direction would cause a smaller magnitude => Double/MAX_VALUE with same sign as start If start is equal to +=Double/MAX_VALUE and direction would cause a larger magnitude => ##Inf or ##-Inf with sign matching start See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#nextAfter-double-double-

Examples

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

(deftest test-next-after
  (is (NaN? (m/next-after ##NaN 1)))
  (is (NaN? (m/next-after 1 ##NaN)))
  (is (pos-zero? (m/next-after 0.0 0.0)))
  (is (neg-zero? (m/next-after -0.0 -0.0)))
  (is (= Double/MAX_VALUE (m/next-after ##Inf 1.0)))
  (is (pos-zero? (m/next-after Double/MIN_VALUE -1.0))))