ClojureDocs

Nav

Namespaces

log10

clojure.math

Available since 1.11
  • (log10 a)
Returns the logarithm (base 10) of a.
If a is ##NaN or negative => ##NaN
If a is ##Inf => ##Inf
If a is zero => ##-Inf
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#log10-double-
1 Example
;; Let's calculate the pH when 1g of hydrochloric acid is added to 2L of water…
(let [HCl-grams 1
      H2O-litres 2
      HCl-molar-mass 36.46
      HCl-moles (/ HCl-grams HCl-molar-mass)
      ;; HCl is a strong acid, so dissociates completely in water
      molarity (/ HCl-moles H2O-litres)]
  ;; pH is calculated as pH = -log₁₀([H⁺])
  (- (math/log10 molarity)))
;; => 1.8628466599829387
See Also

Returns the natural logarithm (base e) of a. If a is ##NaN or negative => ##NaN If a is ##Inf =>...

Added by tomdl89
0 Notes
No notes for log10