SDL Component Suite - Math1

The unit MATH1 offers several fundamental arithmetic operators and mathematical/logical routines which have not been implemented in Delphi™ 1.0 (e.g. hyperbolic functions, tangens, cotangens, or common logarithm). The unit also contains routines to sort data, to produce different numeric formats, to generate random numbers of special distributions, etc. More details can be found in the online help pages.

The unit MATH1 is part of the SDL Component Suite.
 
 


What's new:

  • Release 12.0   [Dec-12, 2023]
     
    • implemented an overlaid version of QuickSelect which addresses the speed problem if there are many equal data values
    • the function Hex has been extended to provide up to 16 hex digits
    • HexToDouble and HexToSingle have been extended by an overloaded version which allows to control the endianess of the input string
    • bug fix: RoundNeg125, RoundPos125 and Round125 did not deliver exact integer values (were off by approx. 1e-15)

  • Release 10.7   [Aug-24, 2020]
     
    • the function modr calculates the remainder of a floating point division
    • the function Squash calculates a sigmoid function
    • the function InterpolXYTable now supports both ascending and descending pivot tables
    • the new function ProductConsecInts calculates the product of consecutive integers

  • Release 10.6   [Mar-09, 2018]
     
    • the function RoundLimit rounds a number within in an interval
    • the function WithinBounds has been extended by the additional parameter Margin
    • the new function CcwTriangle tests the order of triangle corners
    • the new function SortSwap exchanges two values if they do not satisfy the sort criterion
    • the function SegmentsIntersect checks whether to line segments intersect
    • the function DistanceToSegment calculates the distance between a point and a line segment
    • the function HistoBinRef calculates the bin reference value of a histogram
    • the function DistFromEllipse calculates the distance between a point and an ellipse
    • the functions Min and Max have been removed (use unit system.math instead)
    • the functions MinMaxOfArray and MeanVarOfArray have been renamed to MinMaxArray and MeanVarArray and moved to OpenArrays

  • Release 10.5   [Oct-10, 2016]
     
    • the functions ConfineValue and ConfinePointToRect adjust a value or a point to be inside a specified range or rectangle
    • the function MinMaxOfArray returns the minimum and maximum of an array
    • the function MeanVarOfArray returns the mean and the variance of an array
    • the function InterpolTable interpolates a function defined by regularly spaced pivot points
    • the function InterpolXYTable interpolates a function defined by irregularly spaced pivot points
    • the function EuclideanDistance is now available in a second overloaded version
    • bug fix: QuickSelect was too slow if all values in an array were the same
    • bug fix: QuickSelect crashed for small unusual data sets

  • Release 10.4   [Jun-02, 2015]
     
    • no changes

  • Release 10.3   [Oct-06, 2014]
     
    • the new function ListOfPrimes returns the first 4792 prime numbers
    • the new function FindPrimeFactors performs the factorization of numbers
    • the new function WithinRect checks whether a point lies within a rectangle
    • the new function CenteredPolynomial calculates a centered polynomial
    • bug fix: QuickSelect is now much faster if there are many equal values in the data array
    • bug fix: DegreeToStr did not show the negative sign for values between 0 and -1 degree

  • Release 10.2   [May-30, 2013]
     
    • the function QuickSelect returns the k-th smallest value of an array

  • Release 10.1   [Oct-29, 2012]
     
    • new function Polynomial implemented
    • new function CRandom returns Cauchy distributed random numbers

  • Release 10.0   [Oct-4, 2011]
     
    • new function ConvertEndian rearranges the bytes of numeric values from little to big endian and vice versa
    • new function InterpolZofXYRect calculates the z value at a particular position of a simple 3D surface
    • bug fix: function DegreeToStr now creates minutes and seconds (e.g. 3°0' instead of 2°60') the correct way

  • Release 9.7   [May-31, 2010]
     
    • new function CheckPowerOfTwo checks if an integer number is a power of two
    • new function DistFromRect calculates the distance from a rectangular region
    • bug fix: IsValidDecInt returns now correct result for isolated minus or plus signs

  • Release 9.51   [Dec-01, 2008]
     
    • no changes

  • Release 9.5   [Oct-31, 2008]
     
    • CalcScalePars now allows to force tick marks at integer values along the axis
    • new fucntion EEngStr converts floating point numbers to unit prefix notation
    • new procedures to store and load floating point numbers as IEEE hex strings: FPNumToHex, HexToDouble, HexToExtended, HexToSingle
    • new procedure RoundDegrees implemented
    • ScanDegrees now allows to omit the degree symbol if the input string is terminated by a geographic direction ('N','S', 'E', or 'W').
    • bug fix: function DegreeToStr now creates minutes and seconds (e.g. 3°0' instead of 2°60') the correct way

  • Release 9.0   [May-28, 2007]
     
  • Release 8.5   [Feb-18, 2006]
     
  • Release 8.2   [Nov-03, 2004]
     
    • no changes

  • Release 8.1   [Aug-29, 2004]
     
    • available for Delphi™ 8 for .NET
    • function Roman implemented (converts to Roman numbers)
    • new function IsValidDouble implemented
    • class TRandGen has been moved to unit STATIS
    • bug fix: SortArray does no longer crash if called with arrays having only one element

  • Release 8.0   [Apr-15, 2004]
     
    • new function DegreeToStr implemented
    • new function Round125 implemented
    • new functions EuclideanDistance and AngleToXAxís
    • function Sign renamed to Signum in order to avoid confusion with Sign function of unit Math
    • ConvertDegrees implemented
    • ScanDegrees implemented
    • new overloaded versions of Exchange
    • new overloaded versions of SortArray, InsertIntoArray, and SortIntoArray
    • function Factorial implemented
    • TRandGen is now a component
    • bug fix: function Octal now allows up to 11 digits (i.e. to display full 32 bit numbers)

  • Release 7.2   [Mar-23, 2003]
     
    • MATH1 is now part of MathPack
    • ScanDateTime implemented
    • ScanFPNum: changed behavior if DecPChar equals 3: another dot/comma stops parsing without an error

  • Release 7.0   [Sep-15, 2002]
     
    • available for Delphi™ 7.0
    • the unit is now CLX compatible
    • math constants have been moved to new unit UNIVCONST

  • Release 6.5   [May-28, 2002]
     
    • available for C++Builder™ 6.0
    • procedure CancelFraction implemented
    • new function IsPrime tests for prime numbers

  • Version 6.0 [Aug-06, 2001]
     
    • available for Delphi™ 6.0
    • AbortMathProc implemented
    • StrToIntDefault implemented
    • bug fix: SortIntoArray, InsertIntoArray, SortArray now work correctly with "single" floating point numbers
    • bug fix: ScanDecimal now works correctly with empty strings
       
  • Version 5.5  [Jun-09, 2000]
     
    • available now for C++Builder™ 5
    • function BitReversal implemented
       
  • Version 5.0  [Oct-09, 1999]
     
    • MATH1 now available for Delphi™ 5.0
    • bug fix in ScanFPNum: '-23.' no longer produces wrong results (caused by bug in Delphi™ (2.0))
    • bug fix in ScanFPNum: function no longer crashes if value are above MaxDouble or below -MaxDouble
    • EncodeLong and DecodeLong implemented
       
  • Version 1.8  [Mar-23,1999]
     
    • MATH1 now available for C++Builder™ 4.0
    • bug fixed in TRandgen.Normalize (crashed when reference points were all equal)
    • TSortExchgEvent implemented
       
  • Version 1.7     [Aug-17, 1998]
     
    • MATH1 is now available for Delphi™ 4.0
    • sqrt2pi implemented
    • sqrt2pitom1 implemented
    • ScanFPNum now accepts colons and/or dots as decimal points
    • ScanFPNum can accept now either floating point numbers only or exponentional notation (parameter AllowExp)
    • new constants: minReal, MinSingle, MinDouble, MinExtended
    • bug fix in ScanBin: function returned wrong result
       
  • Release 1.6 (Apr-09, 1998)
     
    • MATH1 is now available for all versions of Delphi™ (1.0, 2.0, 3.0), and for C++Builder™ (1.0 and 3.0)
    • ScanHex, ScanOctal, and ScanBin improved to avoid arithmetic overflow if Bit 32 is set.
    • SortArray, SortIntoArray, InsertIntoArray: length of array is now integer instead of word to allow more than 65536 elements to be sorted
    • bug in SortArray fixed which caused wrong result for arrays of length one
    • Exchange is now part of MATH1 (formerly in DCOMMON)
    • CalcScalePars is now part of MATH1 (formerly in DCOMMON)
    • math constants are now part of MATH1 (formerly in DCOMMON)
    • DCOMMON no longer needed
    • definition of call back routine has been moved from MATH2 to MATH1
    • call back routine for SortArray implemented
    • TRandGen.Weibull implemented
       
  • Release 1.5 (May-29, 1997):
     
    • MATH1 is now available for all three versions of Delphi™ and for C++Builder™
    • logarithmus dualis implemented
    • CalcScalePars now available (via dcommon)
    • the routine Decimal now allows for negative numbers
    • routines to scan numeric strings implemented: ScanHex, ScanOctal, ScanBin, ScanDecimal, and ScanFPNum