Next: , Previous: Complex, Up: Numbers

##### 5.5.2.11 Arithmetic Functions

The C arithmetic functions below always takes two arguments, while the Scheme functions can take an arbitrary number. When you need to invoke them with just one argument, for example to compute the equivalent od `(- x)`, pass `SCM_UNDEFINED` as the second one: `scm_difference (x, SCM_UNDEFINED)`.

— Scheme Procedure: + z1 ...
— C Function: scm_sum (z1, z2)

Return the sum of all parameter values. Return 0 if called without any parameters.

— Scheme Procedure: - z1 z2 ...
— C Function: scm_difference (z1, z2)

If called with one argument z1, -z1 is returned. Otherwise the sum of all but the first argument are subtracted from the first argument.

— Scheme Procedure: * z1 ...
— C Function: scm_product (z1, z2)

Return the product of all arguments. If called without arguments, 1 is returned.

— Scheme Procedure: / z1 z2 ...
— C Function: scm_divide (z1, z2)

Divide the first argument by the product of the remaining arguments. If called with one argument z1, 1/z1 is returned.

— Scheme Procedure: 1+ z
— C Function: scm_oneplus (z)

Return z + 1.

— Scheme Procedure: 1- z
— C function: scm_oneminus (z)

Return z - 1.

— Scheme Procedure: abs x
— C Function: scm_abs (x)

Return the absolute value of x.

x must be a number with zero imaginary part. To calculate the magnitude of a complex number, use `magnitude` instead.

— Scheme Procedure: max x1 x2 ...
— C Function: scm_max (x1, x2)

Return the maximum of all parameter values.

— Scheme Procedure: min x1 x2 ...
— C Function: scm_min (x1, x2)

Return the minimum of all parameter values.

— Scheme Procedure: truncate x
— C Function: scm_truncate_number (x)

Round the inexact number x towards zero.

— Scheme Procedure: round x
— C Function: scm_round_number (x)

Round the inexact number x to the nearest integer. When exactly halfway between two integers, round to the even one.

— Scheme Procedure: floor x
— C Function: scm_floor (x)

Round the number x towards minus infinity.

— Scheme Procedure: ceiling x
— C Function: scm_ceiling (x)

Round the number x towards infinity.

— C Function: double scm_c_truncate (double x)
— C Function: double scm_c_round (double x)

Like `scm_truncate_number` or `scm_round_number`, respectively, but these functions take and return `double` values.