integer Class Reference


The integer class defines all the methods needed to handle integer computations. The class integer is a subclass of the class scalar .

Internally, an integer is defined as a C/C++ type long long, ie always 64 bits, as well on an ILP32 CPU than on a LP64 CPU.  Division by 0 or overflow throws an error which can be intercepted by a catch form.

The integer value itself is stored in the car part of a wwlisp cell, beginning at the lowest address, but being 64 bits, cannot be seen completely by the carvalue function on a 32 bits machine.


  • integer-*
  • integer-+
  • integer--
  • integer-/
  • integer-1+
  • integer-1-
  • integer-<
  • integer-=
  • integer->
  • integer-abs
  • integer-base64
  • integer-binary
  • integer-constructor
  • integer-evenp
  • integer-float
  • integer-format
  • integer-gcd
  • integer-hexadecimal
  • integer-integer
  • integer-lcm
  • integer-max
  • integer-min
  • integer-minus
  • integer-minusp
  • integer-oddp
  • integer-random
  • integer-remainder
  • integer-round
  • integer-string
  • integer-unsignedinteger
  • integer-zerop

  • List of all Inherited Classes

  • scalar
  • class

  • integer-*

    (* arg1 ... argn )

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value an integer
    Description returns the product of all the arguments
    Example (* 2 3.0) => 6

    integer-+

    (+ arg1 ... argn )

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value an integer
    Description returns the sum of all the arguments
    Example (+ 1 2 3.0) => 6

    integer--

    (- arg1 ... argn )

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value an integer
    Description returns the result of the successive subtraction of the second argument from the first, the third from the result, the fourth from the result, and so on
    Example (- 5 1 1 1.0) => 2

    integer-/

    (/ arg1 ... arg3 )

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value an integer
    Description returns the result of the successive division of the first argument by the second, the result by the third, the result by the fourth, and so on; in case of overflow or division by 0, an error is thrown
    Example (/ 1000 3 2) => 166

    integer-1+

    (1+ arg )

    Function Type subr
    Arguments an integer
    Return Value an integer
    Description adds 1 to the argument and returns the new value
    Example (1+ 3) => 4

    integer-1-

    (1- arg )

    Function Type subr
    Arguments an integer
    Return Value an integer
    Description subtracts 1 from the argument and returns the new value
    Example (1- 3) => 2

    integer-<

    (< arg1 ... argn)

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value t or nil
    Description returns t if the series of arguments is strictly increasing
    Example (< 1 2 3.0) => t

    integer-=

    (= arg1 arg2 )

    Function Type subr
    Arguments an integer, an unsignedinteger, float or integer
    Return Value t or nil
    Description returns t if the values of the arguments are numerically equal
    Example (= 1 1.0) => t

    integer->

    (> arg1 ... argn)

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value t or nil
    Description returns t if the series of arguments is strictly decreasing
    Example (> 3 2 1.0) => t

    integer-abs

    (abs arg )

    Function Type subr
    Arguments an integer
    Return Value an integer
    Description returns the absolute value of the argument
    Example (abs -1) => 1

    integer-base64

    (base64 arg )

    Function Type subr
    Arguments an integer object
    Return Value a string
    Description returns a string containing the base64 translation of the integer; the length is fixed to 11 characters for the 64 bits integers; endianity is unchanged
    Example (base64 0) => "AAAAAAAAAAA"

    integer-binary

    (binary arg )

    Function Type subr
    Arguments an integer
    Return Value a binary block
    Description returns a binary block containing the integer; the length of the block is 4 bytes on a 32 bits CPU and 8 bytes on a 64 bits CPU
    Example (binary 1)

    integer-constructor

    (make-instance integer)

    Function Type subr
    Arguments none
    Return Value an integer
    Description returns an integer initialized at zero; never use directly integer-constructor , but do it always through make-instance or implicit creation
    Example (make-instance integer) => 0

    integer-evenp

    (evenp arg )

    Function Type subr
    Arguments an integer
    Return Value t or nil
    Description returns t if the argument is even, nil if odd
    Example (evenp 2) => t

    integer-float

    (float arg )

    Function Type subr
    Arguments an integer
    Return Value a float
    Description returns a float with the value of the argument
    Example (float 3) => 3.000000

    integer-format

    (format arg )

    Function Type subr
    Arguments an integer
    Return Value a string
    Description returns a string containing the formatted value of the object passed as argument; is the default formatter of the class integer
    Example (format 33) => "33"

    integer-gcd

    (gcd arg1 ... argn )

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value an integer
    Description returns the greatest common dividing value of the arguments
    Example (gcd 49 1001) => 7

    integer-hexadecimal

    (hexadecimal arg )

    Function Type subr
    Arguments an integer object
    Return Value a string
    Description returns a string containing the hexadecimal translation of the integer; the length is variable with the leading zeroes suppressed; endianity is MSB: most significant bits are on the left;
    Example (hexadecimal 240) => "f0"

    integer-integer

    (integer arg )

    Function Type subr
    Arguments an integer
    Return Value an integer
    Description returns the argument; needed when converting an argument which can be float or integer
    Example (integer x)

    integer-lcm

    (lcm arg1 ... argn )

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value an integer
    Description returns the least common multiple of the arguments
    Example (lcm 2 3 5) => 30

    integer-max

    (max arg1 ... argn )

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value an integer
    Description returns the highest, most positive argument
    Example (max 1 2 3) => 3

    integer-min

    (min arg1 ... argn )

    Function Type subr
    Arguments an integer, an unlimited number of floats or integers
    Return Value an integer
    Description returns the lowest, most negative argument
    Example (min 1 2 -3) => -3

    integer-minus

    (minus arg )

    Function Type subr
    Arguments an integer
    Return Value an integer
    Description returns the opposite of the argument
    Example (minus 1) => -1

    integer-minusp

    (minusp arg )

    Function Type subr
    Arguments an integer
    Return Value t or nil
    Description returns t if the argument is negative
    Example (minusp 0) => nil

    integer-oddp

    (oddp arg )

    Function Type subr
    Arguments an integer
    Return Value t or nil
    Description returns t if the argument is odd
    Example (oddp 1) => t

    integer-random

    (random arg )

    Function Type subr
    Arguments an integer
    Return Value an integer
    Description returns a random integer comprised between 0 and the argument
    Example (random 10)

    integer-remainder

    (remainder arg1 arg2 )

    Function Type subr
    Arguments an integer, an integer or a float
    Return Value an integer
    Description returns the remainder of the integer division of the first argument by  the second, ie the modulo
    Example (remainder 10 3) => 1

    integer-round

    (round arg )

    Function Type subr
    Arguments an integer
    Return Value an integer
    Description returns the integer given as argument; the function allows to do rounding on a scalar without to know in advance if it is a float (where the method is part of the class) or an integer where it was not yet defined
    Example (round 33) => 33

    integer-string

    (string arg )

    Function Type subr
    Arguments an integer
    Return Value a string
    Description returns a string which contains the formatted integer value
    Example (string -1000) => "-1000"

    integer-unsignedinteger

    (unsignedinteger arg )

    Function Type subr
    Arguments an integer
    Return Value an unsignedinteger
    Description returns an unsignedinteger containing the value of the argument; the function is much like a C cast, and does not truncate negative values, but rather returns a bit pattern
    Example (unsignedinteger -1000) => 0xfffffc18

    integer-zerop

    (zerop arg )

    Function Type subr
    Arguments an integer
    Return Value t or nil
    Description returns t if the argument is zero
    Example (zerop 0) => t

    Updated 29/11/2008 Copyright © 2008 Walther Waeles
    SourceForge.net Logo