Real
Module with operation on REAL type.
- Ported from Oberon System 3/4:
ETH Oberon, Copyright 2001 ETH Zuerich Institut fuer Computersysteme, ETH Zentrum, CH-8092 Zuerich. Refer to the “General ETH Oberon System Source License” contract available at: http://www.oberon.ethz.ch/
- Double precision:
1 bit for the sign 11 bits for the exponent 52 bits for the mantissa 64 bits = 8 bytes for one double precision floating point number
The exponent is stored as an unbiased exponent, to get the real exponent (within range -1022..1024) you have to subtract 1023 from the resulting number). The number 0 is represented as exponent = 0 and mantissa = 0. An exponent of 2047 and a mantissa of 0 denotes infinity. An exponent of 2047 and a mantissa of #0 denotes NaN.
Const
FPZero* = Const.FPZero;
FPNormal* = Const.FPNormal;
FPSubnormal*= Const.FPSubnormal;
FPInfinite* = Const.FPInfinite;
FPNaN* = Const.FPNaN;
E* = 2.71828182845904523536;
PI* = 3.14159265358979323846;
PIDIV2* = 1.57079632679489661923;
PIDIV4* = 0.785398163397448309616;
SQRT2* = 1.41421356237309504880;
EPS* = 2.220446E-16;
MINIMUM* = 2.2250738585072014E-308;
MAXIMUM* = 1.7976931348623158E308;
Procedures
FPClassify
Categorizes floating point value. Return either FPNormal, FPZero, FPNaN, FPInfinite or FPSubnormal.
PROCEDURE FPClassify*(x : REAL): INTEGER;
IsNan
Return TRUE if x is a NaN (not a number), and FALSE otherwise.
PROCEDURE IsNan*(x : REAL): BOOLEAN;
IsInf
Return TRUE if x is a positive or negative infinity, and FALSE otherwise.
PROCEDURE IsInf*(x : REAL): BOOLEAN;
IsFinite
Return TRUE if x is neither an infinity nor a NaN, and FALSE otherwise.
PROCEDURE IsFinite*(x : REAL): BOOLEAN;
IsZero
Return TRUE if x is Zero and FALSE otherwise.
PROCEDURE IsZero*(x : REAL): BOOLEAN;
IsNormal
Return TRUE if x is neither an infinity nor a NaN or Zero, and FALSE otherwise.
PROCEDURE IsNormal*(x : REAL): BOOLEAN;
SignBit
Return TRUE if sign bit is set.
PROCEDURE SignBit*(x : REAL): BOOLEAN;
CopySign
Return a REAL with the magnitude (absolute value) of x but the sign of y.
PROCEDURE CopySign*(x, y : REAL): REAL;
Abs
Return absolute value of x.
PROCEDURE Abs*(x : REAL): REAL;
Floor
Computes the largest integer value not greater than x
PROCEDURE Floor* (x: REAL) : REAL ;
Round
Computes the nearest integer value to x, rounding halfway cases away from zero
PROCEDURE Round* (x: REAL) : REAL ;
Sin
Computes the sine of the angle REAL x in radians
PROCEDURE Sin*(x: REAL): REAL;
Cos
Computes the cosine of the angle REAL x in radians
PROCEDURE Cos*(x: REAL): REAL;
ArcTan
Computes the arc tangent of the value REAL x
PROCEDURE ArcTan*(x: REAL): REAL;
ArcTan2
Computes the arc tangent of y / x using the signs of arguments to determine the correct quadrant.
PROCEDURE ArcTan2*(x, y: REAL): REAL;
Sqrt
Computes the square root of the REAL x
PROCEDURE Sqrt*(x: REAL): REAL;
Log
Computes natural (e) logarithm of x
PROCEDURE Log*(x: REAL): REAL;
Exp
Computes e raised to the power of x
PROCEDURE Exp*(x: REAL): REAL;
Tan
Computes the tangent of the value REAL x in radians
PROCEDURE Tan* (x: REAL): REAL;
Format
Format REAL.
prec : Precision or zero for default value.
width : Total field with. Can overflow if number is bigger.
flags : Exp or Fix formatting supported.
The alignment formatting flags are Left, Right & Center . The Spc flag fills in a blank character for + if the number is positive. The Sign flag fills in a + character if the number is positive. If both Spc and Sign are given then Sign precedes.
PROCEDURE Format*(VAR Writer : Type.Stream; value : REAL; prec: INTEGER; width: LENGTH; flags: SET);
FromString
Convert string str to REAL and start and length into str.
Return TRUE if success.
PROCEDURE FromString*(VAR result: REAL; str-: ARRAY OF CHAR; start, length: INTEGER): BOOLEAN;