Math Functions/Classes
Divider

The Math class contains a standard set of math functions.

Function IsNumber (X: Double): Boolean;
Function IsNumber (X: Single): Boolean;
Function IsInfinite (X: Double): Boolean;
Function IsInfinite (X: Single): Boolean;

Floating-point variables can contain a bit pattern representing NaN (not-a-number) or infinity.  IsNumber determines whether a value is a number (infinity is not a number), and IsInfinite determines whether the value is infinity.

Function Sin (Angle: Double "[Radians]"): Double;
Function Sin (Angle: Single "[Radians]"): Single;
Function Sin (Angle: Double "Degrees"): Double;
Function Sin (Angle: Single  "Degrees"): Single;
Function Cos (Angle: Double "[Radians]"): Double;
Function Cos (Angle: Single "[Radians]"): Single;
Function Cos (Angle: Double "Degrees"): Double;
Function Cos (Angle: Single "Degrees"): Single;
Function Tan (Angle: Double "[Radians]"): Double;
Function Tan (Angle: Single "[Radians]"): Single;
Function Tan (Angle: Double "Degrees"): Double;
Function Tan (Angle: Single "Degrees"): Single;

Determines the sine (Sin), cosine (Cos), or tangent (Tan) of an angle. The function that takes Degrees as a delimiter requires Angle to be in degrees; the other requires Angle to be in radians.  There is a set of functions for both single- and double-precision numbers.

Function ACos (Unit: Double "[To] [Radians]"): Double;
Function ACos (Unit: Single "[To] [Radians]"): Single;
Function ACos (Unit: Double "[To] Degrees"): Double;
Function ACos (Unit: Single "[To] Degrees"): Single;
Function ASin (Unit: Double "[To] [Radians]"): Double;
Function ASin (Unit: Single "[To] [Radians]"): Single;
Function ASin (Unit: Double "[To] Degrees"): Double;
Function ASin (Unit: Single "[To] Degrees"): Single;
Function ATan (Unit: Double "[To] [Radians]"): Double;
Function ATan (Unit: Single "[To] [Radians]"): Single;
Function ATan (Unit: Double "[To] Degrees"): Double;
Function ATan (Unit: Single "[To] Degrees"): Single;
Function ATan (X: Double "[Over]" Y: Double "[To] [Radians]"): Double;
Function ATan (X: Single "[Over]" Y: Single "[To] [Radians]"): Single;
Function ATan (X: Double "[Over]" Y: Double "[To] Degrees"): Double;
Function ATan (X: Single "[Over]" Y: Single "[To] Degrees"): Single;

ACos returns the arccosine of Unit in the range 0 to π radians or 0 to 180 degrees. If Unit is less than -1 or greater than 1, ACos returns an NaN.

ASin returns the arcsine of Unit in the range -π/2 to π/2 radians or -90 to 90 degrees. If Unit is less than -1 or greater than 1, ACos returns an NaN.

The first version of ATan returns the arctangent of Unit, in the range -π/2 to π/2 radians, or -90 to 90 degrees.  The second version (the one that takes two arguments) returns the arctangent of X/Y, using the signs of both parameters to determine the result.  The range of the returned angle is therefore -π to π radians, or -180 to 180 degrees.  If Unit is 0, ATan returns 0.  If X and Y are 0, ATan returns 0.

Function CopySign ("[To]" X: Double "[From]" Y: Double): Double;
Function CopySign ("[To]" X: Single "[From]" Y: Single): Single;

CopySign returns X with the same sign as Y. There is no error return.

Function Ceiling ("[Double]" Double X): Double;
Function Ceiling ("Integer" Double X): Integer;

These functions calculate the ceiling of a value--that is, the lowest integer that is greater than or equal to a value.  The first version of the function returns it in the form of a Double; the second version returns it in the form of an Integer.

Function Floor  ("[Double]" Double X): Double;
Function Floor ("Integer" Double X): Integer;

These functions calculate the floor of a value--that is, the highest integer that is less than or equal to a value.  The first version of the function returns it in the form of a Double; the second version returns it in the form of an Integer.

Function Mod (X: Double "[By]" Y: Double): Double;
Function Mod (X: Double "[By]" Y: Double; I: Double @): Double;
Function Mod (X: Double "[By]" Y: Double; I: Integer @): Double;

Mod returns the floating-point remainder of X / Y (and, optionally, the integer portion of the division in I) such that X = I * Y + R, where I is an integer and has the same sign as X, R is the remainder and has the same sign as X, and the absolute value of R is less than the absolute value of Y. If the value of Y is 0.0, Mod returns a NaN.

Function RotateLeft (X: UInt8 "[By]" Shift: Integer): UInt8;
Function RotateLeft (X: UInt16 "[By]" Shift: Integer): UInt16;
Function RotateLeft (X: UInt32 "[By]" Shift: Integer): UInt32;
Function RotateLeft (X: UInt64 "[By]" Shift: Integer): UInt64;
Function RotateRight (X: UInt8 "[By]" Shift: Integer): UInt8;
Function RotateRight (X: UInt16 "[By]" Shift: Integer): UInt16;
Function RotateRight (X: UInt32 "[By]" Shift: Integer): UInt32;
Function RotateRight (X: UInt64 "[By]" Shift: Integer): UInt64;

RotateLeft rotates X left by Shift bits, wrapping high-order bits into the low-order section of the number.  RotateRight rotates X right by Shift bits, wrapping low-order bits into the high-order section of the number. There is a version of this function for each of the four common magnitudes of integers.

 Function Log (X: Double): Double;
 Function Log10 (X: Double): Double;

Log calculates the natural logarithm of X; Log10 calculates the base-10 logarithm of X. If X is negative, these functions return a NaN.  If X is 0, they return infinity.

Function Power (X, Y: Double): Double;
Function Power (X, Y: Single): Single;

This function calculates X raised to the power of Y.  If Y is 0, 1 is returned regardless of the value of X.  If X is 0 and Y is less than 0, infinity is returned.

Function Random (): Double;
Function Random (X: Integer): Integer;
Function Random (Low: Integer "To" High: Integer): Integer;

These functions return pseudo-random numbers.  The no-argument version returns a number below one and greater than or equal to zero.  The single argument version returns a number below X and greater than or equal to zero.  An assertion checks that X is above zero.  The two-argument version returns a number between Low and High inclusive; an assertion checks that Low is less than High.

Function SeedRandom (Seed: UInteger(0));

Sets the starting point for generating a series of pseudorandom numbers using Random.

Function Min (X: Integer; Y: Integer): Integer;
Function Min (X: Double; Y: Double): Double;
Function Max (X: Integer; Y: Integer): Integer;
Function Max (X: Double; Y: Double): Double;

Min returns the lesser of X and Y; Max returns the greater of X and Y.

Function Limit (X: Integer "[To] Between" Min: Integer "[And]" Max: Integer): Integer;
Function Limit (X: Double "[To] Between" Min: Double "[And]" Max: Double): Double;

Limit ensures that X is in the range of Min and Max.  Its returns the result of:

X > Max ? Max : (X < Min ? Min : X)

That Min is less than Max may be checked with an assertion.

Table of Contents Qwertie's Site/Mirror
Next
Previous
Hosted by www.Geocities.ws

1