Unit bigdecimalmath_template
Description
Overview
Classes, Interfaces, Objects and Records
Name | Description |
---|---|
Record BigDecimal |
Big Decimal type |
Functions and Procedures
function TryStrToBigDecimal(const s: string; res: PBigDecimal; errCode: PBigDecimalErrorCode = nil): boolean; |
function StrToBigDecimal(const s: string): BigDecimal; inline; |
function BigDecimalToStr(const v: BigDecimal; format: TBigDecimalFormat = bdfExact): string; |
function BigDecimalToT_NativeInt_(const a: BigDecimal): T_NativeInt_; |
function BigDecimalToExtended(const a: BigDecimal): Extended; |
operator :=(const a: T_NativeInt_): BigDecimal; |
operator :=(const a: Extended): BigDecimal; deprecated 'Direct casting of float to bigdecimal might lead to rounding errors. Consider using StrToBigDecimal.'; |
operator -(const a: BigDecimal): BigDecimal; |
operator +(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
operator -(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
operator *(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
operator /(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
operator div(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
operator mod(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
operator **(const a: BigDecimal; const b: int64): BigDecimal; |
procedure divideModNoAlias(out quotient, remainder: BigDecimal; const a, b: BigDecimal; targetPrecision: integer = 18; flags: TBigDecimalDivisionFlags = [bddfKeepDividentPrecision, bddfKeepDivisorPrecision, bddfAddHiddenDigit]); |
function divide(const a, b: BigDecimal; maximalAdditionalFractionDigits: integer = 18; flags: TBigDecimalDivisionFlags = [bddfKeepDividentPrecision, bddfKeepDivisorPrecision, bddfAddHiddenDigit]): BigDecimal; |
procedure shift10(var v: BigDecimal; shift: integer); |
function shifted10(const v: BigDecimal; shift: integer): BigDecimal; |
function compareBigDecimals(const a, b: BigDecimal): integer; |
operator _OP_(const a: BigDecimal; const b: BigDecimal): boolean; |
procedure normalize(var x: BigDecimal); |
function precision(const v: BigDecimal): integer; |
function round(const v: BigDecimal; toDigit: integer = 0; roundingMode: TBigDecimalRoundingMode = bfrmRound): BigDecimal; overload; |
function roundInRange(mi, exact, ma: BigDecimal): BigDecimal; |
function getDigit(const v: BigDecimal; digit: integer): BigDecimalBin; |
procedure setZero(out r: BigDecimal); |
procedure setOne(out r: BigDecimal); |
function isZero(const v: BigDecimal): boolean; overload; |
function isIntegral(const v: BigDecimal): boolean; |
function isLongint(const v: BigDecimal): boolean; |
function isInt64(const v: BigDecimal): boolean; |
function odd(const v: BigDecimal): boolean; overload; |
function even(const v: BigDecimal): boolean; overload; |
function abs(const v: BigDecimal): BigDecimal; overload; |
function power(const v: BigDecimal; const exp: Int64): BigDecimal; overload; |
function sqrt(const v: BigDecimal; precision: integer = 9): BigDecimal; overload; |
function gcd(const a,b: BigDecimal): BigDecimal; overload; |
function lcm(const a,b: BigDecimal): BigDecimal; overload; |
function fastpower2to(const exp: Int64): BigDecimal; |
function fastpower5to(const exp: Int64): BigDecimal; |
Types
BigDecimalBin = integer; |
BigDecimalBinSquared = int64; |
PBigDecimal = ˆBigDecimal; |
TBigDecimalErrorCode = (...); |
PBigDecimalErrorCode = ˆTBigDecimalErrorCode; |
TBigDecimalFormat = (...); |
TBigDecimalFloatFormat = (...); |
TBigDecimalDivisionFlags = set of (bddfKeepDividentPrecision, bddfKeepDivisorPrecision, bddfAddHiddenDigit, bddfFillIntegerPart, bddfNoFractionalPart); |
TBigDecimalRoundingMode = (...); |
Constants
DIGITS_PER_ELEMENT = 9; |
ELEMENT_OVERFLOW = 1000000000; |
Description
Functions and Procedures
function TryStrToBigDecimal(const s: string; res: PBigDecimal; errCode: PBigDecimalErrorCode = nil): boolean; |
Converts a decimal string to a bigdecimal. |
function StrToBigDecimal(const s: string): BigDecimal; inline; |
Converts a decimal string to a bigdecimal. |
function BigDecimalToStr(const v: BigDecimal; format: TBigDecimalFormat = bdfExact): string; |
Converts a bigdecimal to a decimal string |
function BigDecimalToT_NativeInt_(const a: BigDecimal): T_NativeInt_; |
Converts a bigdecimal to a native int (can overflow) |
function BigDecimalToExtended(const a: BigDecimal): Extended; |
Converts a bigdecimal to an extended (may introduce rounding errors) |
operator :=(const a: T_NativeInt_): BigDecimal; |
Converts a native integer to a BigDecimal |
operator :=(const a: Extended): BigDecimal; deprecated 'Direct casting of float to bigdecimal might lead to rounding errors. Consider using StrToBigDecimal.'; |
Warning: this symbol is deprecated: Direct casting of float to bigdecimal might lead to rounding errors. Consider using StrToBigDecimal.
Converts an extended to a BigDecimal |
operator -(const a: BigDecimal): BigDecimal; |
Standard operator unary - |
operator +(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
Standard operator binary + |
operator -(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
Standard operator binary - |
operator *(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
Standard operator binary * |
operator /(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
Standard operator binary / |
operator div(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
Standard operator binary div |
operator mod(const a: BigDecimal; const b: BigDecimal): BigDecimal; |
Standard operator binary mod |
operator **(const a: BigDecimal; const b: int64): BigDecimal; |
Standard operator binary ** |
procedure divideModNoAlias(out quotient, remainder: BigDecimal; const a, b: BigDecimal; targetPrecision: integer = 18; flags: TBigDecimalDivisionFlags = [bddfKeepDividentPrecision, bddfKeepDivisorPrecision, bddfAddHiddenDigit]); |
Universal division/modulo function. Calculates the quotient and remainder of a / b. Parameters
|
function divide(const a, b: BigDecimal; maximalAdditionalFractionDigits: integer = 18; flags: TBigDecimalDivisionFlags = [bddfKeepDividentPrecision, bddfKeepDivisorPrecision, bddfAddHiddenDigit]): BigDecimal; |
Wrapper around divideModNoAlias, ignoring the calculated remainder |
procedure shift10(var v: BigDecimal; shift: integer); |
Calculates a decimal shift: |
function shifted10(const v: BigDecimal; shift: integer): BigDecimal; |
Calculates a decimal shift: |
function compareBigDecimals(const a, b: BigDecimal): integer; |
Compares the big decimals. Returns -1, 0 or 1 corresponding to a <, = or > b |
operator _OP_(const a: BigDecimal; const b: BigDecimal): boolean; |
procedure normalize(var x: BigDecimal); |
Removes leading (pre .) and trailing (post .) zeros |
function precision(const v: BigDecimal): integer; |
How many non-zero digits the number contains |
function round(const v: BigDecimal; toDigit: integer = 0; roundingMode: TBigDecimalRoundingMode = bfrmRound): BigDecimal; overload; |
Universal rounding function |
function roundInRange(mi, exact, ma: BigDecimal): BigDecimal; |
Given mi < exact < ma, truncate exact to a bigdecimal result, such that |
function getDigit(const v: BigDecimal; digit: integer): BigDecimalBin; |
Returns the digit-th digit of v. |
procedure setZero(out r: BigDecimal); |
Sets the bigdecimal to 0 |
procedure setOne(out r: BigDecimal); |
Sets the bigdecimal to 1 |
function isZero(const v: BigDecimal): boolean; overload; |
Returns true iff the bigdecimal is zero |
function isIntegral(const v: BigDecimal): boolean; |
Returns true iff v has no fractional digits |
function isLongint(const v: BigDecimal): boolean; |
Returns true iff v has no fractional digits and can be stored within an longint (32 bit integer) |
function isInt64(const v: BigDecimal): boolean; |
Returns true iff v has no fractional digits and can be stored within an int64 |
function odd(const v: BigDecimal): boolean; overload; |
Checks if v is |
function even(const v: BigDecimal): boolean; overload; |
Checks if v is |
function abs(const v: BigDecimal): BigDecimal; overload; |
Returns the absolute value of v |
function power(const v: BigDecimal; const exp: Int64): BigDecimal; overload; |
Calculates v ** exp, with exp being an integer |
function sqrt(const v: BigDecimal; precision: integer = 9): BigDecimal; overload; |
Calculates the square root of v, to precision digits after the decimal point |
function gcd(const a,b: BigDecimal): BigDecimal; overload; |
Calculates the greatest common denominator (only makes sense for positive integer input) |
function lcm(const a,b: BigDecimal): BigDecimal; overload; |
Calculates the least common multiple |
function fastpower2to(const exp: Int64): BigDecimal; |
Calculates 2 ** exp exactly, with exp being an integer (faster than power for negative exp) |
function fastpower5to(const exp: Int64): BigDecimal; |
Calculates 5 ** exp exactly, with exp being an integer (faster than power for negative exp) |
Types
BigDecimalBin = integer; |
BigDecimalBinSquared = int64; |
PBigDecimal = ˆBigDecimal; |
TBigDecimalErrorCode = (...); |
Values
|
PBigDecimalErrorCode = ˆTBigDecimalErrorCode; |
TBigDecimalFormat = (...); |
Values
|
TBigDecimalFloatFormat = (...); |
Values
|
TBigDecimalDivisionFlags = set of (bddfKeepDividentPrecision, bddfKeepDivisorPrecision, bddfAddHiddenDigit, bddfFillIntegerPart, bddfNoFractionalPart); |
TBigDecimalRoundingMode = (...); |
Values
|
Constants
DIGITS_PER_ELEMENT = 9; |
ELEMENT_OVERFLOW = 1000000000; |
Generated by PasDoc 0.16.0.