| Introduction Inspirations |
categories Primitives Integers and Floats |
Dates and Times |
Both floats and integers are CLAIRE primitives. integers are represented using 30 bits (which is required for the OID model) and are always signed. Floats are represented as C double precision floating point numbers.
Arithmetic between integers and float can be handled using conversion method integer! and float! :
| 1 + 2 -> 3 1 + 2. -> error 1 + integer!(2.) -> 3 float!(1) + 2. -> 3. |
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
returns the product of two floats
| categories | Integers and Floats | inline | operation | Kernel method |
returns the product of two integers
| categories | Integers and Floats | normal dispatch | operation | Core method |
returns the sum of two integers
| categories | Integers and Floats | normal dispatch | operation | Core method |
returns the sum of two floats
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
returns the opposite of x (i.e. -1.0 * x)
| categories | Integers and Floats | inline | operation | Kernel method |
returns the opposite of x
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
returns the difference of two integers
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
returns the difference of two floats
| categories | Integers and Floats | inline | operation | Kernel method |
returns the division of two integers
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
returns the division of two floats
| categories | Integers and Floats | inline | operation | Kernel method |
returns true if x is lower than y
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
returns true if x is lower than y
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
(x << n) is the result of shifting the integer x seen as a bitvector to the left by n positions.
| categories | Integers and Floats | inline | operation | Kernel method |
returns true if x is lower or equal to y
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
returns true if x is lower or equal to y
| categories | Integers and Floats | inline | operation | Kernel method |
returns true if x is greater than y
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
returns true if x is greater than y
| categories | Integers and Floats | inline | operation | Kernel method |
returns true if x is greater or equal to y
| categories | Integers and Floats | inline | operation | Kernel method |
returns true if x is greater or equal to y
| categories | Integers and Floats | normal dispatch | operation | Core method |
(x >> n) is the result of shifting the integer x seen as a bitvector to the right by n positions.
| categories | Integers and Floats | inline | operation | Kernel method |
(x ^ y) returns the y exponent of x. y must be a positive integer, otherwise an error is raised.
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
(x ^ y) returns the y exponent of x.
| categories | Integers and Floats | inline | Kernel method |
^2(x) returns the 2 exponent of x
| categories | Integers and Floats | normal dispatch | Core method |
acos(self) computes the principal value of the arc cosine of self in the range [0, pi].
| categories | Integers and Floats | normal dispatch | operation | Core method |
and(x,y) returns the bitwise intersection of two integers (seen as bitvectors).
| categories | Integers and Floats | normal dispatch | Core method |
asin(self) computes the principal value of the arc sine of self in the range [-pi/2, +pi/2].
| categories | Integers and Floats | normal dispatch | Core method |
atan(self) returns the principal value of the arc tangent of self in the range [-pi/2, +pi/2].
| categories | Integers and Floats | normal dispatch | [XL] Kernel method |
bin!(i) returns a string representation of the integer i in the binary basis (the length of the string is always 32). The string can only contain '0' and '1' chars
| bin!(0) -> "0000000000000000000000000000000" bin!(1) -> "0000000000000000000000000000001" bin!(12) -> "0000000000000000000000000001100" |
| categories | Integers and Floats | normal dispatch | Kernel method |
char!(n) returns the character which ASCII code is n.
| char!(65) -> 'A' |
| categories | Integers and Floats | normal dispatch | Core method |
cos(self) computes the cosine of self (measured in radians).
| categories | Integers and Floats | normal dispatch | Core method |
cosh(self) computes the hyperbolic cosine of self.
| categories | Integers and Floats | normal dispatch | Core method |
divide?(x,y) returns true if y is a multiple of x.
| categories | Integers and Floats | normal dispatch | Core method |
factor?(x,y) returns true if x is a multiple of y.
| categories | Integers and Floats | normal dispatch | Kernel method |
transforms an integer into a float.
| categories | Integers and Floats | normal dispatch | [XL] Kernel method |
hex!(i) returns a string representation of the integer i in the hexadecimal basis (the length of the string is always 8). The string can only contain chars in the range ('0' .. '9') U ('A' .. 'F').
| hex!(0) -> "00000000" hex!(12) -> "0000000C" hex!(255) -> "000000FF" hex!(256) -> "00000100" |
| categories | Integers and Floats | normal dispatch | Kernel method |
integer!(l) returns the integer represented by the bitvector l, i.e. the sum of all 2i for i in l.
| categories | Integers and Floats | normal dispatch | Kernel method |
integer!(f) returns the lower integer approximation of f
| categories | Integers and Floats | normal dispatch | Core method |
log(x) returns the value of the natural logarithm of argument x.
| categories | Integers and Floats | normal dispatch | Core method |
make_set(x) returns the set of bit index that are set in the integer x seen as a bitvector.
| categories | Integers and Floats | normal dispatch | operation | Core method |
returns the greatest float
| categories | Integers and Floats | normal dispatch | operation | Core method |
returns the greatest integer
| categories | Integers and Floats | Language constant |
This global variable is the greatest supported integer in CLAIRE. This is a 30 bit value (integers in CLAIRE are coded on 30 bits). This value can be used in code that require a big integer value as in the following sample :
| my_min(l:list[integer]) : integer -> let minima := MAX_INTEGER in (for i in l (if (i < minima) minima := i), minima) |
| categories | Integers and Floats | normal dispatch | operation | Core method |
returns the lowest float
| categories | Integers and Floats | normal dispatch | operation | Core method |
returns the lowest integer
| categories | Integers and Floats | normal dispatch | operation | Kernel method |
mod(x,y) is the rest of the Euclidean division of x by y (modulo).
| categories | Integers and Floats | inline | Kernel method |
nth(n,i) returns true if the ithdigit of n in base 2 is 1. nth(n,i) is equivalent to n[i].
| categories | Integers and Floats | normal dispatch | operation | Core method |
or(x, y) returns the bitwise union of two integers (seen as bitvectors).
| categories | Integers and Floats | normal dispatch | Kernel method |
random(n) returns an integer in (0 .. n-1), supposedly with uniform probability.
| categories | Integers and Floats | normal dispatch | [XL] Kernel method |
random!() resets the seed with the current UNIX time value for the random number generator process.
| categories | Integers and Floats | normal dispatch | Kernel method |
random!(n) resets the seed for the random number generator process.
| categories | Integers and Floats | normal dispatch | Core method |
sin(self) computes the sine of self (measured in radians).
| categories | Integers and Floats | normal dispatch | Core method |
sinh(self) computes the hyperbolic sine.
| categories | Integers and Floats | normal dispatch | Core method |
returns the square root of x. Returns an irrelevant value when x is strictly negative.
| categories | Integers and Floats | normal dispatch | Kernel method |
make a new string from a float x.
| categories | Integers and Floats | normal dispatch | Kernel method |
make a new string from an integer n.
| categories | Integers and Floats | normal dispatch | Core method |
tan(self) computes the tangent of self (measured in radians).
| categories | Integers and Floats | normal dispatch | Core method |
tanh(self) computes the hyperbolic tangent of self.