Contents | < Browse | Browse >
9G. math and other functions
a:=And(b,c) a:=Or(b,c) a:=Not(b)
These work with the usual operations, boolean as well as arithmetic.
Note that for And() and Or() an operator exists.
Performs the same operation as the '*' and '/' operators, but now in
full 32bit. For speed reasons, normal operations are 16bit*16bit=32bit
and 32bit/16bit=16bit. This is sufficient for nearly all calculations,
and where it's not, you may use Mul() and Div(). NOTE: in the Div
case, a is divided by b, not b by a.
Return TRUE or FALSE if some expression is Odd or Even
compute min and max of the two given ints.
Rnd() computes a random number from an internal seed in range 0 .. max-1.
For example, Rnd(1000) returns an integer from 0..999
To initialise the internal seed, call Rnd() with a negative value;
the Abs() of that value will be the initial seed.
RndQ() computes a random number "Q"uicker than Rnd() does, but returns
only full range 32bit random numbers. Use the result as the seed for
the next call, and for startseed, use any large value, like $A6F87EC1
computes the absolute value.
computes the sign of v, i.e. returns -1,0,1
Divides 32bit c by 16bit d and returns 16bit modulo a and optionally
a 16bit result of the division b. If these 16bit limits are exceeded,
Mod() will not give correct results.
arithmatically shifts y num bits to left or right (set new bits to 0).
a:=Long(adr) a:=Int(adr) a:=Char(adr)
peeks into memory at some address, and returns the value found. This
works with 32, 16 and 8 bit values respectively. Note that the compiler does
not check if 'adr' is valid. These functions are available in E for
those cases where reading and writing in memory with PTR TO <type>
would only make a program more complex or less efficient. You are _not_
encouraged to use these functions.
PutLong(adr,a) PutInt(adr,a) PutChar(adr,a)
Pokes value 'a' into memory. See: Long()
makes sure x lies between bounds a and b, and adjust acordingly if necessary.
It equals: y:=IF x<a THEN a ELSE IF x>b THEN b ELSE x