util/arithmetic.lsp [src]
Functions related to basic math
(acos ang)
Returns the arccosine of ANG (radians)
VARS:
(ANG nil (NUMBERP ANG))
(ceil n)
Returns the smallest integer greater than or equal to N
VARS:
(N nil (NUMBERP N))
TESTS:
(= (CEIL 0.1) 1)
(= (CEIL 1) 1)
(= (CEIL -0.9) 0)
(dec! int-sym)
Decrements INT-SYM destructively
VARS:
(INT-SYM SYM (NUMBERP (VL-SYMBOL-VALUE INT-SYM)))
(inc! int-sym)
Increments INT-SYM destructively
VARS:
(INT-SYM SYM (NUMBERP (VL-SYMBOL-VALUE INT-SYM)))
(is-even n)
Returns nil if N is not divisible by 2
VARS:
(N INT)
TESTS:
(NOT (IS-EVEN 1))
(IS-EVEN 2)
(post-dec! int-sym)
Returns the value of INT-SYM then decrement it destructively
VARS:
(INT-SYM SYM (NUMBERP (VL-SYMBOL-VALUE INT-SYM)))
(post-inc! int-sym)
Returns the value of INT-SYM then increment it destructively
VARS:
(INT-SYM SYM (NUMBERP (VL-SYMBOL-VALUE INT-SYM)))
(rnd-dn num prc)
Rounds NUM down to the next multiple of precision PRC
VARS:
(NUM nil (NUMBERP NUM))
(PRC nil (NUMBERP PRC))
TESTS:
(= (RND-DN 1.3 0.25) 1.25)
(= (RND-DN 1.9 0.5) 1.5)
(rnd-up num prc)
Rounds NUM up to the next multiple of precision PRC
VARS:
(NUM nil (NUMBERP NUM))
(PRC nil (NUMBERP PRC))
TESTS:
(= (RND-UP 1.1 0.25) 1.25)
(= (RND-UP 1.1 0.5) 1.5)
(square n)
Returns the square of N
VARS:
(N nil (NUMBERP N))
TESTS:
(= (SQUARE 2) 4)
(= (SQUARE -3) 9)
(tan ang)
Returns the tangent of ANG (radians)
VARS:
(ANG nil (NUMBERP ANG))
TESTS:
(= (TAN 0) 0.0)