Unit WANumUtl

Renamed from NumUtils.pas 6/14/1998 Paul Rice to avoid conflicts with others' work. +----------------------------------------------------------------------------+ | İ İ | | İİ İ İ İ | | İİİ İ İ İ | | İİ İ İ İ | | İ İİ İ İ | | İ İ İİİ İİ İ | | İİ İ İ İİİİİİİİİİ İ | | İ İİ İİ İİİİİİİİİİİİİİİ | | İ İİİ İİİİİİ İİİ İ İİİİİİİİ | | İ İİ İİİİİİİİİİİİ İ İİİİİİİİİİ Copyright İ 1996-1997 by: | | İ İİİİİİ İİİİİİİİİİİ İ İİİİİ İİ | | İ İİİİİİİ İİİİİ İİİİ İİ İİ İ WHITE ANTS SYSTEMHOUSE BV | | İ İİİİİİİ İİİ İİİ İİ İ İİİİ Geleen 12 | | İ İİİİİİİ İ İİ İİİ İ 8032 GB Zwolle | | İİİİİİ İ İ İ Netherlands | | İİİ İİİİİ İ İİ İ İ | | İİ İ İ İİİ İ Tel. +31 38 453 86 31 | | İ İ İ Fax. +31 38 453 41 22 | | İ İ İİ | | İ İ İİ www.whiteants.com | | İİ İ İ İ support@whiteants.com | | İ | +----------------------------------------------------------------------------+ file : NumUtils version : 1.0 comment : NumUtils contains numeric utility procedures author : G. Beuze / J. Laarhoven / R. Post compiler : Delphi 1.0 +----------------------------------------------------------------------------+ | DISCLAIMER: | | THIS SOURCE IS FREEWARE. YOU ARE ALLOWED TO USE IT IN YOUR OWN PROJECTS | | WITHOUT ANY RESTRICTIONS, BUT YOU ARE NOT ALLOWED TO SELL IT IN ANY WAY. | | THERE IS NO WARRANTY AT ALL - YOU USE IT ON YOUR OWN RISC. WHITE ANTS DOES | | NOT ASSUME ANY RESPONSIBILITY FOR ANY DAMAGE OR ANY LOSS OF TIME OR MONEY | | DUE THE USE OF ANY PART OF THIS SOURCE CODE. | +----------------------------------------------------------------------------+

Classes

Functions

BitState - Enables ABits bits in State
CompareInt - Returns maximum from x, y
GetMirror - converts order of bytes: $01020304 => $04030201
InRange - Returns 1 if L1 > L2, -1 if L1 < l2 and 0 if L1 = L2
LimitToRange - Returns True if Value >= LowBound and Value <= UpBound
Log2 - Swaps x with y and vice versa
Max2Int - returns minimum from x, y
MaxByte - returns minimum from x, y
MaxFloat - Returns True if State and ABits <> 0 , so if any bit is set } ***************************Floating point utility funtions ****************************

**************************** Floating point utility routines ****************************
MaxLong - returns minimum from x, y
MaxNFloat - Returns minimum from x, y
MaxNInt - ******************** Ordinal type procedures and functions *******************

******************** Ordinal type procedures and functions *******************
MaxWord - returns minimum from x, y
Min2Int - returns minimum of n LongInts, Values must contain at least one item
MinByte - Returns maximum from x, y
MinFloat - Returns maximum from x, y
MinLong - Returns maximum from x, y
MinNFloat - Returns maximum of Values, Values must contain at least one item
MinNInt - returns minimum of n longints, Values must contain at least one item
MinWord - Returns maximum from x, y
MirrorLong - Returns Value if Value in range [LowBound.
PWR - Returns the 2_Log(x) value
SetBits - returns MirrorLong(L)
Sign - returns X^Y, calculated as PWR := Exp(Y * Ln(X)) for X > 0.
SwapFloat - Returns Minimum of Values, Values must contain at least one item

Types

Constants

Variables


Functions


function BitState(State, ABits: Word): Boolean;

Enables ABits bits in State

function CompareInt(L1, L2: LongInt): Integer;

Returns maximum from x, y

function GetMirror(L: LongInt): LongInt;

converts order of bytes: $01020304 => $04030201

function InRange(Value, LowBound, UpBound: LongInt): Boolean;

Returns 1 if L1 > L2, -1 if L1 < l2 and 0 if L1 = L2

function LimitToRange(Value, LowBound, UpBound: LongInt): LongInt;

Returns True if Value >= LowBound and Value <= UpBound

function Log2(X: Extended): Extended;

Swaps x with y and vice versa

function Max2Int(X, Y: Integer): Integer;

returns minimum from x, y

function MaxByte(X, Y: Byte): Byte;

returns minimum from x, y

function MaxFloat(X, Y: Extended): Extended;

Returns True if State and ABits <> 0 , so if any bit is set } ***************************Floating point utility funtions ****************************

**************************** Floating point utility routines ****************************


function MaxLong(X, Y: LongInt): LongInt;

returns minimum from x, y

function MaxNFloat(const Values: array of Extended): Extended;

Returns minimum from x, y

function MaxNInt(const Values: array of LongInt): LongInt;

******************** Ordinal type procedures and functions *******************

******************** Ordinal type procedures and functions *******************


function MaxWord(X, Y: Word): Word;

returns minimum from x, y

function Min2Int(X, Y: Integer): Integer;

returns minimum of n LongInts, Values must contain at least one item

function MinByte(X, Y: Byte): Byte;

Returns maximum from x, y

function MinFloat(X, Y: Extended): Extended;

Returns maximum from x, y

function MinLong(X, Y: LongInt): LongInt;

Returns maximum from x, y

function MinNFloat(const Values: array of Extended): Extended;

Returns maximum of Values, Values must contain at least one item

function MinNInt(const Values: array of LongInt): LongInt;

returns minimum of n longints, Values must contain at least one item

function MinWord(X, Y: Word): Word;

Returns maximum from x, y

procedure MirrorLong(var L: LongInt);

Returns Value if Value in range [LowBound..UpBound] else Low or Up. If range is invalid (LowBound > UpBound) LowBound is returned

function PWR(X, Y : Extended): Extended;

Returns the 2_Log(x) value

procedure SetBits(var State: Word; ABits: Word; Enable: Boolean);

returns MirrorLong(L)

function Sign(X: Extended): LongInt;

returns X^Y, calculated as PWR := Exp(Y * Ln(X)) for X > 0. X MUST be > 0

procedure SwapFloat(var X, Y: Extended);

Returns Minimum of Values, Values must contain at least one item

Types


Constants


Variables