next up previous contents index
Next: Data structures Up: User Guide Previous: User Guide   Contents   Index

Arithmetic

libaldor contains several integer types: MachineInteger provides full-word signed machine integers, while Integer 1provides ``infinite'' precision software integers. Both of them are of category IntegerType, so the same functions can be applied to them. In addition, MachineInteger exports 3 useful constants: min and max, whose values are the smallest and greatest machine integers, and bytes, whose values is the machine wordsize in bytes. The bytes constant allows you to write wordsize-dependent code, for example when generating half-word-size prime numbers. A MachineInteger value n can be coerced to an Integer via n::Integer, and the reverse conversion is provided via the machine function, i.e. n := machine m. This last conversion can of course lose precision if m does not fit within a machine word. The general form for iterating over a range of integers is
for variable in from..to by step | condition repeat { ... }
where the to parameter and the by and ``| condition'' parts are optional.

Besides the integers, libaldor also provides machine floating point numbers, both in single precision (SingleFloat) and double precision (DoubleFloat). Finally, if you are linking with the GMP library, libaldor provides GMPFloat, which is an interface to the ``infinite'' precision software floats of GMP. The above 3 type share the category FloatType.


next up previous contents index
Next: Data structures Up: User Guide Previous: User Guide   Contents   Index
Manuel Bronstein 2004-06-28