Delphi/Kylix Math Functions

Constants

Constants on Dave's Math Tables
www.sisweb.com/math/constants.htm

Favorite Math Constants
http://pauillac.inria.fr/algo/bsolve/constant/constant.html 

Mathematical Constants and Computation
http://xavier.gourdon.free.fr/Constants/constants.html
 
http://xavier.gourdon.free.fr/Constants/Miscellaneous/constantsNumTheory.html 

Knuth's constants to 1000 decimal and 1100 octal places
http://web.comlab.ox.ac.uk/oucl/work/richard.brent/pub/pub036.html 

Constant Name Description Source(s)
Cbrt2, Cbrt3, Cbrt10, Cbrt100, CbrtPi cube  roots of various values ESBMaths
e (natural constant) e = ESBe, e^2 = ESBe2, e^PI = ESBePi, 
e^(PI/2) = ESBePiOn2, e^(PI/4) = ESBePiOn4
ESBMaths
exp(1.0) natural constant (e)
e = 2.718281828459045
system
Euler's Gamma Gamma ESBMaths
High(OrdinalType) where OrdinalType can be Byte, Word, Integer, LongInt, LongWord, Int64,

High(Byte) = 255
High(Word) = 65535
High(LongInt) = 2,147,483,647
High(LongWord) = 4,294,967,295
High(Int64) = 9,223,372,036,854,775,807

ESBMaths
INF Infinity:  See Exploring Numbers, Not-A-Number, and Infinity  
Infinity, NegInfinity CONST
  Infinity    =  1.0 / 0.0;
  NegInfinity = -1.0 / 0.0; 

These constants should only be used in assignments.  Use the IsInfinity function to compare a value with Infinity.

Kylix math
InvSqrt2, InvSqrt3, InvSqrt5, InvSqrtPi, InvCbrtPi Inverse square roots 2, 3, 5 and SQRT(PI), cube root of PI ESBMaths
Ln2, Ln10, LnPi natural logarithms of 2, 10, PI ESBMaths
Ln2 natural logarithm of 2

// Ln(2) = 0.693147180559945344
FUNCTION Ln2: Extended;
ASM
  FLDLN2
  FWAIT
END;

 
Log10Base2 Base 2 logarithm of 10 ESBMaths
Log102 Base-10 logarithm of 2

// Log10(2) = 0.301029995663981184
FUNCTION Log102: Extended;
ASM
  FLDLG2
  FWAIT
END;

 
Log2Base10 Base-10 logarithm of 2 ESBMaths
Log210 // Log2(10) = 3.321928094887362560
FUNCTION Log210: Extended;
ASM
  FLDL2T
  FWAIT
END;
 
Log2E // Log2(E) = 1.442695040888963520
FUNCTION Log2E: Extended;
ASM
  FLDL2E
  FWAIT
END;
 
Log3Base10 Base 10 Log of 3 ESBMaths
LogEBase10 Base 10 Log of e ESBMaths
LogPiBase10 Base 10 Log of PI ESBMaths
Low(OrdinalType) where OrdinalType can be Byte, Word, Integer, LongInt, LongWord, Int64,

Low(Byte) = 0
Low(Word) = 0
Low(LongInt) = -2,147,483,648
Low(LongWord) = 0
Low(Int64) = -9,223,372,036,854,775,808

 
MACHEP 1.08420217248550444E-19, machine precision = 2-63 TPmath1(fmath)
MaxComp 9.223372036854775807E+18 math
MaxDouble 1.7E+308

{$J-}
CONST MaxDoubleBits: Int64 = $7FEFFFFFFFFFFFFF;
VAR MaxDoubleValue: Double ABSOLUTE MaxDoubleBits;

1.79769313486232E308

math
MaxExtended 1.1E+4932 math
MaxFac 1754, highest argument for factorial TPmath1(fmath)
MaxGam 1755.455, highest argument for gamma TPmath1(fmath)
MaxLGm 1.04848146839019521E+4928 TPmath1(fmath)
MaxLog 11356.5234062941439, highest argument for Exp
Ln(MaxNum)
TPmath1(fmath)
MaxNormal {$J-}
CONST MaxNormalBits: Int64 = $7FEFFFFFFFFFFFFF;
VAR   MaxNormal: Double ABSOLUTE MaxNormalBits;

1.7976931348623157E308

 
MaxNum 1.18973149535723103E+4932
216384
TPmath1(fmath)
MaxSingle 3.4E+38 math
MaxSubNormal
{$J-}
CONST MaxSubNormalBits: Int64 = $000FFFFFFFFFFFFF;
VAR   MaxSubNormal: Double ABSOLUTE MaxSubNormalBits;

2.2250738585072009E-308

 
MinComp -9.223372036854775807E+18 math
MinDouble 5.0E-324 math
MinExtended 3.4E-4932 math
MinLog -11355.137111933024, lowest argument for Exp
Ln(MinNum)
TPmath1(fmath)
MinNormal {$J-}
CONST MinNormalBits: Int64 = $0010000000000000;
VAR   MinNormal: Double ABSOLUTE MinNormalBits;

2.2250738585072014E-308

 
MinNum 3.36210314311209558E-4932
2-16382
TPmath1(fmath)
MinSingle 1.5E-45 math
MinSubNormal
{$J-}
CONST MinSubNormalBits: Int64 = $0000000000000001;
VAR   MinSubNormal: Double ABSOLUTE MinSubNormalBits;

4.9406564584124654E-324

 
NaN NaN = Not a Number: 

CONST NaN = 0.0 / 0.0; 

The NaN constant should only be used in assignments.  Use the IsNan function to compare a value with a NaN.

See Exploring Numbers, Not-A-Number, and Infinity

Kylix math
One // 1.000000000000000000
FUNCTION One: Extended;
ASM
  FLD1
  FWAIT
END;
 
OneDegree One degree in radians:
0.017453292519943295769
ESBMaths
OneMinute One minute in radians:
ESBMaths
OneRadian One radian in degrees:
57.295779513082320877
ESBMaths
OneSecond One second in radians ESBMaths
pi pi ~ 3.14159 26535 89793 23846 26433 ...

The verifiable FPU value is 3.14159 26535 89793 28 (decimal) or   $4000C90FDAA22168C235 (hex).

// 3.141592653589793280
// Note: %25.19f gives the same result as %25.2f
// Memo1.Lines.Add(  Format('%25.18f', [PI])  );

// 3.141592653589793280
FUNCTION  InLinePi: Extended;
ASM
  FLDPI
  FWAIT
END;

Ray Lischner in a 29 Aug 1999 UseNet post:  "...the compiler generates inline code  with hardwired integer values to represent the floating point numbers. You get the same  results as the FLDPI instruction, but it's faster because you don't have to move data out of the FPU and you don't have to use the FWAIT instruction."

Delphi uses "compiler magic" for the pi "function," which is evaluated at compile time and not at run time.

inline
pi constants ESBPi, InvPi, TwoPi, ThreePi, Pi^2 = Pi2, Pi^e = PiE, 
Pi/2 = PiOn2, Pi/3 = PiOn3, Pi/4 = Pi/4, 3*Pi/2 = ThreePiOn2, 4*Pi/3 = FourPiOn3
ESBMaths
Sqrt2, Sqrt3, Sqrt5, Sqrt10, SqrtPi square roots of various values ESBMaths
TwoToPower63 9223372036854775808 ESBMaths
Zero // Zero = 0.000000000000000000
FUNCTION Zero: Extended;
ASM
  FLDZ
  FWAIT
END;
 

Sources Key

Source Description/Location
ESBMaths
ESB Consultancy
Developers of Mathematical & Statistical
Software and Delphi Software.
Freeware ESBMaths with Source. www.esbconsult.com
math Borland's Delphi math unit
system Borland's Delphi system unit
TPmath1 Jean DeBord's TPMath
www.unilim.fr/pages_perso/jean.debord/tpmath/tpmath.htm

Links Verified 14 Jul 2000
Updated 30 Aug 2003


since 1 Nov 1998