Copyright (C) 2000-2012 |
GNU Info (guile.info)IntegersIntegers -------- 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. - primitive: integer? obj Return `#t' if OBJ is an integer number, `#f' else. (integer? 487) => #t (integer? -3.4) => #f automatically generated by info2www version 1.2.2.9 |