summaryrefslogtreecommitdiffstats
path: root/math-integer.txi
blob: 9999fb3b748c85ce29cef6e59e3e25e514cd8f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@code{(require 'math-integer)}
@ftindex math-integer


@defun integer-expt n1 n2

Returns @var{n1} raised to the power @var{n2} if that result is an exact
integer; otherwise signals an error.

@code{(integer-expt 0 @var{n2})}

returns 1 for @var{n2} equal to 0;
returns 0 for positive integer @var{n2};
signals an error otherwise.
@end defun


@defun integer-log base k

Returns the largest exact integer whose power of @var{base} is less than or
equal to @var{k}. If @var{base} or @var{k} is not a positive exact integer, then
@code{integer-log} signals an error.
@end defun


@defun integer-sqrt k

For non-negative integer @var{k} returns the largest integer whose square
is less than or equal to @var{k}; otherwise signals an error.
@end defun


@defun quotient n1 n2

@defunx remainder n1 n2
@defunx modulo n1 n2
are redefined so that they accept only exact-integer arguments.
@end defun


@defun round-quotient n1 n2

Returns the quotient of @var{n1} and @var{n2} rounded toward even.

@example
(quotient 3 2)        @result{} 1
(round-quotient 3 2)  @result{} 2
@end example
@end defun