Introduction
Inspirations
categories
Primitives
Integers and Floats
Dates and Times

Primitives

Integers and Floats

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 Floatsnormal dispatch operationKernel method

*(self:float, x:float) -> float

returns the product of two floats


categories Integers and Floatsinline operationKernel method

*(x:integer, y:integer) => integer

returns the product of two integers


categories Integers and Floatsnormal dispatch operationCore method

+(self:integer, x:integer) -> type[abstract_type(+, self, x)]

returns the sum of two integers


categories Integers and Floatsnormal dispatch operationCore method

+(self:float, x:float) -> float

returns the sum of two floats


categories Integers and Floatsnormal dispatch operationKernel method

-(x:float) -> float

returns the opposite of x (i.e. -1.0 * x)


categories Integers and Floatsinline operationKernel method

-(x:integer) => integer

returns the opposite of x


categories Integers and Floatsnormal dispatch operationKernel method

-(self:integer, x:integer) -> type[Core/abstract_type(-, Core/self, Core/x)]

returns the difference of two integers


categories Integers and Floatsnormal dispatch operationKernel method

-(self:float, x:float) -> float

returns the difference of two floats


categories Integers and Floatsinline operationKernel method

/(x:integer, y:integer) => integer

returns the division of two integers


categories Integers and Floatsnormal dispatch operationKernel method

/(self:float, x:float) -> float

returns the division of two floats


categories Integers and Floatsinline operationKernel method

<(x:float, y:float) => boolean

returns true if x is lower than y


categories Integers and Floatsnormal dispatch operationKernel method

<(x:integer, y:integer) -> boolean

returns true if x is lower than y


categories Integers and Floatsnormal dispatch operationKernel method

<<(x:integer, n:integer) -> integer

(x << n) is the result of shifting the integer x seen as a bitvector to the left by n positions.


categories Integers and Floatsinline operationKernel method

<=(x:float, y:float) => boolean

returns true if x is lower or equal to y


categories Integers and Floatsnormal dispatch operationKernel method

<=(x:integer, y:integer) -> boolean

returns true if x is lower or equal to y


categories Integers and Floatsinline operationKernel method

>(x:float, y:float) => boolean

returns true if x is greater than y


categories Integers and Floatsnormal dispatch operationKernel method

>(x:integer, y:integer) -> boolean

returns true if x is greater than y


categories Integers and Floatsinline operationKernel method

>=(x:integer, y:integer) => boolean

returns true if x is greater or equal to y


categories Integers and Floatsinline operationKernel method

>=(x:float, y:float) => boolean

returns true if x is greater or equal to y


categories Integers and Floatsnormal dispatch operationCore method

>>(x:integer, n:integer) -> integer

(x >> n) is the result of shifting the integer x seen as a bitvector to the right by n positions.


categories Integers and Floatsinline operationKernel method

^(x:integer, y:integer) => integer

(x ^ y) returns the y exponent of x. y must be a positive integer, otherwise an error is raised.


categories Integers and Floatsnormal dispatch operationKernel method

^(self:float, x:float) -> float

(x ^ y) returns the y exponent of x.


categories Integers and Floatsinline Kernel method

^2(x:integer) => void

^2(x) returns the 2 exponent of x


categories Integers and Floatsnormal dispatch Core method

acos(self:float) -> float

acos(self) computes the principal value of the arc cosine of self in the range [0, pi].


categories Integers and Floatsnormal dispatch operationCore method

and(x:integer, y:integer) -> integer

and(x,y) returns the bitwise intersection of two integers (seen as bitvectors).


categories Integers and Floatsnormal dispatch Core method

asin(self:float) -> float

asin(self) computes the principal value of the arc sine of self in the range [-pi/2, +pi/2].


categories Integers and Floatsnormal dispatch Core method

atan(self:float) -> float

atan(self) returns the principal value of the arc tangent of self in the range [-pi/2, +pi/2].


categories Integers and Floatsnormal dispatch [XL] Kernel method

bin!(i:integer) -> string

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 Floatsnormal dispatch Kernel method

char!(n:integer) -> char

char!(n) returns the character which ASCII code is n.
 char!(65-> 'A'


categories Integers and Floatsnormal dispatch Core method

cos(self:float) -> float

cos(self) computes the cosine of self (measured in radians).


categories Integers and Floatsnormal dispatch Core method

cosh(self:float) -> float

cosh(self) computes the hyperbolic cosine of self.


categories Integers and Floatsnormal dispatch Core method

divide?(x:integer, y:integer) -> boolean

divide?(x,y) returns true if y is a multiple of x.


categories Integers and Floatsnormal dispatch Core method

factor?(x:integer, y:integer) -> boolean

factor?(x,y) returns true if x is a multiple of y.


categories Integers and Floatsnormal dispatch Kernel method

float!(x:integer) -> float

transforms an integer into a float.


categories Integers and Floatsnormal dispatch [XL] Kernel method

hex!(i:integer) -> string

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 Floatsnormal dispatch Kernel method

integer!(s:set[integer]) -> integer

integer!(l) returns the integer represented by the bitvector l, i.e. the sum of all 2i for i in l.


categories Integers and Floatsnormal dispatch Kernel method

integer!(f:float) -> integer

integer!(f) returns the lower integer approximation of f


categories Integers and Floatsnormal dispatch Core method

log(x:float) -> float

log(x) returns the value of the natural logarithm of argument x.


categories Integers and Floatsnormal dispatch Core method

make_set(x:integer) -> set

make_set(x) returns the set of bit index that are set in the integer x seen as a bitvector.


categories Integers and Floatsnormal dispatch operationCore method

max(x:float, y:float) -> float

returns the greatest float


categories Integers and Floatsnormal dispatch operationCore method

max(x:integer, y:integer) -> integer

returns the greatest integer


categories Integers and Floats Language constant

MAX_INTEGER :: 1073741822

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 < minimaminima := i),
         minima)


categories Integers and Floatsnormal dispatch operationCore method

min(x:float, y:float) -> float

returns the lowest float


categories Integers and Floatsnormal dispatch operationCore method

min(x:integer, y:integer) -> integer

returns the lowest integer


categories Integers and Floatsnormal dispatch operationKernel method

mod(x:integer, y:integer) -> integer

mod(x,y) is the rest of the Euclidean division of x by y (modulo).


categories Integers and Floatsinline Kernel method

nth(n:integer, i:integer) => any

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 Floatsnormal dispatch operationCore method

or(x:integer, y:integer) -> integer

or(x, y) returns the bitwise union of two integers (seen as bitvectors).


categories Integers and Floatsnormal dispatch Kernel method

random(n:integer) -> integer

random(n) returns an integer in (0 .. n-1), supposedly with uniform probability.


categories Integers and Floatsnormal dispatch [XL] Kernel method

random!() -> void

random!() resets the seed with the current UNIX time value for the random number generator process.


categories Integers and Floatsnormal dispatch Kernel method

random!(n:integer) -> void

random!(n) resets the seed for the random number generator process.


categories Integers and Floatsnormal dispatch Core method

sin(self:float) -> float

sin(self) computes the sine of self (measured in radians).


categories Integers and Floatsnormal dispatch Core method

sinh(self:float) -> float

sinh(self) computes the hyperbolic sine.


categories Integers and Floatsnormal dispatch Core method

sqrt(self:float) -> float

returns the square root of x. Returns an irrelevant value when x is strictly negative.


categories Integers and Floatsnormal dispatch Kernel method

string!(self:float) -> string

make a new string from a float x.


categories Integers and Floatsnormal dispatch Kernel method

string!(n:integer) -> string

make a new string from an integer n.


categories Integers and Floatsnormal dispatch Core method

tan(self:float) -> float

tan(self) computes the tangent of self (measured in radians).


categories Integers and Floatsnormal dispatch Core method

tanh(self:float) -> float

tanh(self) computes the hyperbolic tangent of self.