next up previous contents
Next: Matrices Up: Input Previous: Input

Numbers

Decimal integers can be given in octal, decimal and hexadecimal form. Octal integers begin with a 0 (zero) and hexadecimal integers with a 0x (zero x). For example 077;, 63; and 0x3f; are valid inputs of the integer 63. Integers are represented in lc by the type bigint.

LC Session

lc> 077 == 63;
$7 = true
lc> 0x3f == 63;
$8 = true
lc>

Rational numbers are given as a quotient of two integers. For example 1/-2; is a valid input of a rational number. The numerator and denominator are represented in lowest terms, i.e. for every rational number n/d we have: gcd(n, d) = 1 and d is positive. Rationals are represented in lc by the type bigrational.

LC Session

lc> 1/-2; 
$9 = -1/2
lc> 2/-4 == -1/2;
$10 = true
lc>

Real numbers can be given in floating-point scientific notation. For example 3.14, 0.314e1 or 314e-2 are valid inputs. Real numbers are represented in lc by the type bigfloat.

LC Session

lc> 3.14 == 0.314e1; 
$11 = true
lc>

Complex numbers are given in in the form a +- b * I where a, b can be of type bigint, bigrational or bigfloat. I denotes the imaginary unit. For example, 1/2 - 3.14*I; is a valid input. Complex numbers are represented in lc by the type bigcomplex.

LC Session

lc> 1/2 - 3.14*I; 
$12 = 0.5 - 3.14*I
lc> I * I == -1; 
$13 = true
lc>



Thomas Papanikolaou
Thu Aug 28 10:25:48 MET DST 1997