Assignment
An assigment allows to put a value into a memory, thus to give a value to a variable. This value may be a literal or be contained inside another variable.In all cases, one can only assign to a variable a value having the same type.
Examples:
x = 1200 ... x may be of any numerical type
z = 0.5 ... z must be a real or a number
t = "abc" ... t must be text.
A literal integer is a number without decimal point.
A real number is identified by the decimal point or e, for "exponent".
Examples:
number z z = 110 ... ok, 110 is an integer thus a number
z = 110.0 ... ok, a point denotes a real.
z = 1e5 ... ok.
The number type allows to convert a number from a base to any other base.
To convert a number into text, the toText() method may be used. The toInt() and toNumber() methods convert a text into integer or real providing that the text is a string of digits.
Example, not really useful, just to be clear:
text t = 10.toText()
int x = "1200".toInt()
Examples of assignment | int
x text t = "234" x = t.toInteger() print x |
Display: | > 234 |
Exercises |
1) Declare and assigne the right variable for these
values: 10, "example", 0.5, array(1,2,3) Answer |