Up | Next | Prev | PrevTail | Tail |
Conversions between numeric types are provided explicitly by the FIX and FLOAT functions and implicitly by any multi-parameter arithmetic function which receives mixed types of arguments. A conversion from fixed to floating point numbers may result in a loss of precision without a warning message being generated. Since integers may have a greater magnitude that that permitted for floating numbers, an error may be signaled when the attempted conversion cannot be done. Because the magnitude of integers is unlimited the conversion of a floating point number to a fixed number is always possible, the only loss of precision being the digits to the right of the decimal point which are truncated. If a function receives mixed types of arguments the general rule will have the fixed numbers converted to floating before arithmetic operations are performed. In all cases an error occurs if the parameter to an arithmetic function is not a number:
***** XXX parameter to FUNCTION is not a number
XXX is the value of the parameter at fault and FUNCTION is the name of the function that detected the error. Exceptions to the rule are noted where they occur.
EXPR PROCEDURE ABS(U); |
IF LESSP(U, 0) THEN MINUS(U) ELSE U; |
EXPR PROCEDURE ADD1(U); |
PLUS2(U, 1); |
***** Attempt to divide by 0 in DIVIDE
EXPR PROCEDURE DIVIDE(U, V); |
(QUOTIENT(U, V) . REMAINDER(U, V)); |
***** Argument to FLOAT is too large
MACRO PROCEDURE MAX(U); |
EXPAND(CDR U, ’MAX2); |
EXPR PROCEDURE MAX2(U, V); |
IF LESSP(U, V) THEN V ELSE U; |
MACRO PROCEDURE MIN(U); |
EXPAND(CDR U, ’MIN2); |
EXPR PROCEDURE MIN2(U, V); |
IF GREATERP(U, V) THEN V ELSE U; |
EXPR PROCEDURE MINUS(U); |
DIFFERENCE(0, U); |
MACRO PROCEDURE PLUS(U); |
EXPAND(CDR U, ’PLUS2); |
***** Attempt to divide by 0 in QUOTIENT
***** Attempt to divide by 0 in REMAINDER
EXPR PROCEDURE REMAINDER(U, V); |
DIFFERENCE(U, TIMES2(QUOTIENT(U, V), V)); |
EXPR PROCEDURE SUB1(U); |
DIFFERENCE(U, 1); |
MACRO PROCEDURE TIMES(U); |
EXPAND(CDR U, ’TIMES2); |
Up | Next | Prev | PrevTail | Front |