Contents | Prev | Next | Index


Standard Function Procedures

Name Description
ABS(x) absolute value; result type = argument type
CAP(x) capital letter.
CHR(x) character with ordinal number x: CHR(x)=VAL(CHAR,x)
FLOAT(x) x of integer or cardinal type converted to REAL
HIGH(a) cardinal high index bound of array a
LONG(x) extended value of x:
SHORTINT->INTEGER,
INTEGER->LONGINT,
SHORTCARD->CARDINAL,
CARDINAL->LONGCARD,
SHORTREAL->LONGREAL
LONGFLOAT(x) x of integer or cardinal type converted to LONGREAL
LONGTRUNC(x) real number x truncated to its integral part of type LONGINT.
MAX(T) maximum value of type T, where T is a basic type (except reals), an enumeration or a subrange type
MIN(T) minimum value of type T, where T is a basic type (except reals), an enumeration or a subrange type.
ODD(x) boolean ( x MOD 2 = 1 )
ORD(x) ordinal number (of a cardinal type with same size than that of x) in the set of values defined by type T of x. T is any enumeration type, CHAR, SHORTINT, INTEGER, LONGINT, SHORTCARD, CARDINAL, or LONGCARD.
SHORT(x) size truncated value of x:
LONGINT->INTEGER,
INTEGER->SHORTINT,
LONGCARD->CARDINAL,
CARDINAL->SHORTCARD,
LONGREAL->SHORTREAL
SHORTFLOAT(x) x of integer or cardinal type converted to LONGREAL
SHORTTRUNC(x) real number x truncated to its integral part of type SHORTINT.
SIZE(T) cardinal number of bytes of a specified non-structured type T.
SIZE(x) cardinal number of bytes required by a variable x of a non-structured type
TRUNC(x) real number x truncated to its integral part of type INTEGER.
VAL(T,x) the value with ordinal number x and with type T. T is any enumeration type, CHAR, SHORTINT, INTEGER, LONGINT, SHORTCARD, CARDINAL, LONGCARD or BOOLEAN. VAL(T,ORD(x))=x, if x of type T.

Note: Unlike other Modula-2 implementations, this compiler does not accept structured types for the standard SIZE function. It is because structured types are mapped to Java classes or Java arrays, and they as well as all of their structured components are allocated accross uncontiguous different memory allocation blocks from the Java heap, with internal references pointing to them. Java Virtual Machines may also implement different alignment schemes. Hence, simply adding up the total size of the component types for a structured type wouldn't always yield a meaningful result.


Contents | Prev | Next | Index

Canterbury Modula-2 for Java  (Last documentation update Feb 8, 2000)
Copyright © 1998 Mill Hill & Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to mhc@webcom.com