Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Numbers   [Contents][Index]


6.6.2.7 Operations on Integer Values

Scheme Procedure: odd? n
C Function: scm_odd_p (n)

Return #t if n is an odd number, #f otherwise.

Scheme Procedure: even? n
C Function: scm_even_p (n)

Return #t if n is an even number, #f otherwise.

Scheme Procedure: quotient n d
Scheme Procedure: remainder n d
C Function: scm_quotient (n, d)
C Function: scm_remainder (n, d)

Return the quotient or remainder from n divided by d. The quotient is rounded towards zero, and the remainder will have the same sign as n. In all cases quotient and remainder satisfy n = q*d + r.

(remainder 13 4) ⇒ 1
(remainder -13 4) ⇒ -1

See also truncate-quotient, truncate-remainder and related operations in Arithmetic.

Scheme Procedure: modulo n d
C Function: scm_modulo (n, d)

Return the remainder from n divided by d, with the same sign as d.

(modulo 13 4) ⇒ 1
(modulo -13 4) ⇒ 3
(modulo 13 -4) ⇒ -3
(modulo -13 -4) ⇒ -1

See also floor-quotient, floor-remainder and related operations in Arithmetic.

Scheme Procedure: gcd x…
C Function: scm_gcd (x, y)

Return the greatest common divisor of all arguments. If called without arguments, 0 is returned.

The C function scm_gcd always takes two arguments, while the Scheme function can take an arbitrary number.

Scheme Procedure: lcm x…
C Function: scm_lcm (x, y)

Return the least common multiple of the arguments. If called without arguments, 1 is returned.

The C function scm_lcm always takes two arguments, while the Scheme function can take an arbitrary number.

Scheme Procedure: modulo-expt n k m
C Function: scm_modulo_expt (n, k, m)

Return n raised to the integer exponent k, modulo m.

(modulo-expt 2 3 5)
   ⇒ 3
Scheme Procedure: exact-integer-sqrt k
C Function: void scm_exact_integer_sqrt (SCM k, SCM *s, SCM *r)

Return two exact non-negative integers s and r such that k = s^2 + r and s^2 <= k < (s + 1)^2. An error is raised if k is not an exact non-negative integer.

(exact-integer-sqrt 10) ⇒ 3 and 1

Next: , Previous: , Up: Numbers   [Contents][Index]