LargeDecimal Class
Description
The LargeDecimal class is used to store very large (or very small) decimal values. This is done by storing a String containing the digits (with the decimal point and leading and trailing zeroes removed) and a power of ten as an Integer.
Example
LargeDecimal.PlacesCalculated:
largedecimal1:
largedecimal2:
largedecimal1.ToString() largedecimal2.ToString()
largedecimal1.Absolute() largedecimal2.Absolute()
largedecimal1.IsIntegral() largedecimal2.IsIntegral()
largedecimal1.Truncate() largedecimal2.Truncate()
largedecimal1.Truncate(3) largedecimal2.Truncate(3)
-largedecimal1 -largedecimal2
 
largedecimal1 + largedecimal2 = largedecimal1 < largedecimal2 =
largedecimal1 - largedecimal2 = largedecimal2 < largedecimal1 =
largedecimal2 - largedecimal1 = largedecimal1 > largedecimal2 =
largedecimal1 * largedecimal2 = largedecimal2 > largedecimal1 =
largedecimal1 / largedecimal2 = largedecimal1 = largedecimal2 =
largedecimal2 / largedecimal1 = largedecimal1 <> largedecimal2 =
largedecimal1 Mod largedecimal2 = largedecimal1 <= largedecimal2 =
largedecimal2 Mod largedecimal1 = largedecimal2 <= largedecimal1 =
largedecimal1 >= largedecimal2 =
largedecimal2 >= largedecimal1 =
Properties & Methods
LargeDecimal
  • Digits - A String containing the digits that are used when calculating or displaying values. When this has a value of String.Empty, the value is 0
  • Exponent - An Integer which is the power that 10 is raised to when calculating or displaying values
  • Sign - An Integer specifying whether the value is positive or negative
  • PlacesCalculated - An Integer specifying the number of decimal places to calculate when doing division using the / operator, default is 10. This is a shared property for all instances of the LargeDecimal class
  • IsIntegral - A ReadOnly Boolean value that indicates whether the value is an integer
LargeDecimal()Constructor that creates a LargeDecimal with a value of 0 LargeDecimal(value As String)Constructor that accepts a decimal value as a string
  • value - Any String that can be converted to a decimal value
LargeDecimal(value As Decimal) LargeDecimal(value As Double)Constructor that creates a LargeDecimal from a value of type Decimal or Double
  • value - The Decimal or Double whose value is to be used
LargeDecimal(sgn As Integer,dgt As String,exp As Integer)Constructor that creates a large decimal from a String of digits and a power of 10
  • sgn - An Integer specifying the sign
  • dgt - A String of digits
  • exp - The power to which 10 should be raised
ToString()Displays the value in a standard decimal format Truncate() Truncate(3)Returns a LargeDecimal with no more than the specified number of digits to the right of the decimal Absolute()Returns the absolute value as a LargeDecimal Defined Operators:
  • + - Addition
  • - - Subtraction
  • * - Multiplication
  • / - Division
  • - - Negation
  • < - Less Than
  • > - Greater Than
  • = - Equality
  • <> - Inequality
  • <= - Less Than Or Equal To
  • >= - Greater Than Or Equal To
  • Mod - Modulus
Defined Type Conversions (narrowing):
  • LargeDecimal to SByte
  • LargeDecimal to Byte
  • LargeDecimal to Short
  • LargeDecimal to UShort
  • LargeDecimal to Integer
  • LargeDecimal to UInteger
  • LargeDecimal to Long
  • LargeDecimal to ULong
  • LargeDecimal to Decimal
  • LargeDecimal to Single
  • LargeDecimal to Double
  • Fraction to LargeDecimal
  • LargeDecimal to Fraction
  • LDFraction to LargeDecimal
Defined Type Conversions (widening):
  • Long to LargeDecimal
  • ULong to LargeDecimal
  • Decimal to LargeDecimal
  • Double to LargeDecimal
  • LargeDecimal to LDFraction
Source Code
LargeDecimal.vb:

Remarks
When using the division operator (/), values are always rounded towards 0. In other words, positive values are rounded down, and negative values are rounded up.