DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH

# (guile.info.gz) Integers Info Catalog (guile.info.gz) Numerical Tower (guile.info.gz) Numbers (guile.info.gz) Reals and Rationals
```
21.2.2 Integers
---------------

Integers are whole numbers, that is numbers with no fractional part,
such as 2, 83 and -3789.

Integers in Guile can be arbitrarily big, as shown by the following
example.

(define (factorial n)
(let loop ((n n) (product 1))
(if (= n 0)
product
(loop (- n 1) (* product n)))))

(factorial 3)
=>
6

(factorial 20)
=>
2432902008176640000

(- (factorial 45))
=>
-119622220865480194561963161495657715064383733760000000000

Readers whose background is in programming languages where integers
are limited by the need to fit into just 4 or 8 bytes of memory may find
this surprising, or suspect that Guile's representation of integers is
inefficient.  In fact, Guile achieves a near optimal balance of
convenience and efficiency by using the host computer's native
representation of integers where possible, and a more general
representation where the required number does not fit in the native
form.  Conversion between these two representations is automatic and
completely invisible to the Scheme level programmer.

-- Scheme Procedure: integer? x
-- C Function: scm_integer_p (x)
Return `#t' if X is an integer number, else `#f'.

(integer? 487)
=>
#t

(integer? -3.4)
=>
#f

``` Info Catalog (guile.info.gz) Numerical Tower (guile.info.gz) Numbers (guile.info.gz) Reals and Rationals
automatically generated byinfo2html