Skip to content

jsl/math

Package name: jsl/math

Summary

General Definitions

Function Description
in-range? Check if a value is within the passed range (inclusive)
scaled-series
round-places Round a given value to a given number of places after the decimal.
rounded-log10
get-power-of-10 Determine the power of 10 series that this value is from.

Definitions

General Definitions

in-range?

Check if a value is within the passed range (inclusive)

public defn in-range? (v:Double, minV:Double, maxV:Double) -> True|False

  • v: Double - Value to query
  • minV: Double - minimum value of the range
  • maxV: Double - maximum value of the range
  • Returns True|False

scaled-series

public defn scaled-series (x:Double, exp:Double) -> Double

  • Returns Double

round-places

Round a given value to a given number of places after the decimal.

public defn round-places (v:Double, places:Int) -> Double

  • v: Double - Value to round
  • places: Int - Number of places after the decimal to round to. This value must be greater than 0.
  • Returns Double - Value rounded to a certain number of places.

rounded-log10

public defn rounded-log10 (v:Int, N:Int, places:Int) -> Double

  • Returns Double

get-power-of-10

Determine the power of 10 series that this value is from.

public defn get-power-of-10 (v:Double) -> Double

  • Returns Double
  val A = 532.0
  println("power10[A] = %_" % [get-power-of-10(A)])

  val B = 0.34
  println("power10[B] = %_" % [get-power-of-10(B)])

  ; prints:
  ; power10[A] = 2
  ; power10[B] = -1