PSC Code Manual

util/arithmetic.lsp [src]

Functions related to basic math

Functions

Function signature Description
(acos ang) Returns the arccosine of ANG (radians)
(ceil n) Returns the smallest integer greater than or equal to N
(dec! int-sym) Decrements INT-SYM destructively
(inc! int-sym) Increments INT-SYM destructively
(is-even n) Returns nil if N is not divisible by 2
(post-dec! int-sym) Returns the value of INT-SYM then decrement it destructively
(post-inc! int-sym) Returns the value of INT-SYM then increment it destructively
(rnd-dn num prc) Rounds NUM down to the next multiple of precision PRC
(rnd-up num prc) Rounds NUM up to the next multiple of precision PRC
(square n) Returns the square of N
(tan ang) Returns the tangent of ANG (radians)

(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)