Docs
chromia.com

TYPE

decimal

On this page
type decimal

A real number data type with high precision.

Not a complete equivalent of floating-point types, as there are a fixed maximum number of digits before the decimal point (131072, or 2^17 digits) and after the decimal point (20 digits).

Examples:

  • 123.456
  • .789
  • 7e+33
  • decimal('123456789.98765')

Since 0.9.1

Attributes

PRECISION: integer = 131092

The maximum number of digits a decimal can have (131072 before the decimal point and 20 after, i.e. 131092).

Since 0.9.1

SCALE: integer = 20

The maximum number of decimal digits after the decimal point (20).

Since 0.9.1

INT_DIGITS: integer = 131072

The maximum number of digits before the decimal point (131072).

Since 0.9.1

MIN_VALUE: decimal = 1E-20

The smallest nonzero absolute value that a decimal can store (0.00000000000000000001).

Since 0.9.1

MAX_VALUE: decimal = 999999999999999999999999999999999999999999999999999999999999999999999999

The largest value that a decimal can store (1E+131072 - 1).

Since 0.9.1

Methods

abs
Returns the absolute value of this decimal; i.e. the decimal itself if it's positive or its negation
ceil
Round this decimal away from zero, to the next whole number.
decimal
floor
Round this decimal towards zero, to the next whole number.
from_text
Parse a signed base-10 text representation of a real number.
max
Returns the greater of this and another decimal value; i.e. value if value is greater than this,
min
Returns the lesser of this and another decimal value; i.e. value if value is less than this, or
round
Round this decimal to the nearest whole number.
sign
Returns the sign of this decimal: -1 if negative, 0 if zero, and 1 if positive.
signum
Returns the sign of this decimal: -1 if negative, 0 if zero, and 1 if positive.
to_big_integer
Convert this decimal to a biginteger, truncating the fractional part.
to_integer
Convert this decimal to an integer, truncating the fractional part.
to_text
Convert this decimal to a base 10 text representation.