Import std.math.big.decimal
std.math.big.decimal
Decimal: a decimal number, over mpdecimal, which never changes once it's made. It holds what it's made from exactly, as 0.1 is, and its arithmetic keeps 28 significant digits, rounded half to even, as Python's decimal does by default, so 1 / 3 is 0.3333333333333333333333333333. A result's exponent stays from -999999 to 999999: past that panics, and below it goes toward 0. Trailing 0s stay, as in 1.50, and ToString shows them, but == doesn't count them, so 1.5 == 1.50. An Int64 on either side of an operator works too. A Decimal stays on its thread, so ToString and Parse are how one goes to another.
std/math/big/decimal.fb
Types
RoundingMode
enum
Public Enum RoundingMode
How rounding treats what it drops.
std/math/big/decimal.fb, line 43
-
To the nearest, and a half to the even one, as banks round: 2.5 to 2, and 3.5 to 4.
-
To the nearest, and a half away from 0: 2.5 to 3, and -2.5 to -3.
-
To the nearest, and a half toward 0: 2.5 to 2, and -2.5 to -2.
-
Away from 0: 2.1 to 3, and -2.1 to -3.
-
Toward 0, dropping the rest: 2.9 to 2, and -2.9 to -2.
-
Up: 2.1 to 3, and -2.9 to -2.
-
Down: 2.9 to 2, and -2.1 to -3.
Decimal
class
Public Class Decimal Implements Comparable, Hashable, Printable, Numeric
A decimal number, which holds what it's made from exactly, as 0.1 is, and keeps 28 significant digits in its arithmetic.
std/math/big/decimal.fb, line 62
-
The Decimal of
value. -
The Decimal of
value. -
The number that adding leaves alone: 0.
Doc from
std.core.interfaces.Numeric.Zero. -
The number that multiplying leaves alone: 1.
Doc from
std.core.interfaces.Numeric.One. -
The shortest Decimal that reads back as the Double, the digits it prints, so 0.1 is 0.1. A NaN or an infinity panics.
-
The number the
textis, exactly: a sign or none, then digits with a "." or not, then an exponent or none, an "E" or "e" and an integer, as "-1.50" and "2.5e-3" are. Other text, NaN and the infinities too, is Null. -
What Python's str gives: its digits with a point where it goes, as in "-1.50", unless its exponent is above 0 or it's quite small, as in "1.5E+3" and "1E-7".
-
Its digits with no exponent, as in "1500" and "0.0000001".
-
The Double nearest it, ties to even: an infinity past the largest Double, and 0 below the smallest.
-
It as an Int64, or Null when it isn't a whole number in an Int64's range.
-
It as a BigInt, or Null when it isn't a whole number.
-
-1, 0, or 1 as it's below, at, or above 0.
-
Whether it's a whole number, as 2.00 and 1E+3 are.
-
Its distance from 0: the same Decimal, without its sign.
-
@PanicsAtCaller Public Method Round(places: Int = 0, mode: RoundingMode = RoundingMode.HALF_EVEN): Decimalmethod #It rounded by the
modeto theplacesafter the point, or before it when negative: 2.675 is 2.68 to 2places, and 1234 is 1.2E+3 to -2. Rounding to more digits than 28, or than it has when that's more, panics, and so does a result whose exponent is past 999999 either way, as with Python's quantize. -
It rounded to a whole number, toward 0, down, or up. One with an exponent above 0 keeps it, as 1.5E+3 does.
-
It rounded down to a whole number, toward negative infinity.
-
It rounded up to a whole number, toward positive infinity.
-
Its square root. One below 0 panics.
-
e to its power.
-
Its natural logarithm, and its logarithm in base 10. One that isn't above 0 panics.
-
Its base 10 logarithm. Panics unless it's above 0.
-
It to the power, which needn't be whole: 2 to 0.5 is the square root of 2. Anything to 0 is 1, 0 to a power below 0 panics, and so does a number below 0 to one that isn't whole.
-
Its hash, the same for values that are equal.
Doc from
std.core.interfaces.Hashable.Hash. -
Whether
aandbare equal.Doc from
std.core.interfaces.Equatable.Operator==. -
Whether
aandbare equal. -
Whether
aandbare equal. -
Whether
acomes beforeb.Doc from
std.core.interfaces.Comparable.Operator<. -
Whether
acomes beforeb. -
Whether
acomes beforeb. -
Whether
acomes afterb. -
Whether
acomes afterb. -
Whether
acomes beforebor is equal to it. -
Whether
acomes beforebor is equal to it. -
Whether
acomes afterbor is equal to it. -
Whether
acomes afterbor is equal to it. -
aandbadded up.Doc from
std.core.interfaces.Numeric.Operator+. -
aplusb. -
aplusb. -
btaken away froma.Doc from
std.core.interfaces.Numeric.Operator-. -
aminusb. -
aminusb. -
aandbmultiplied together.Doc from
std.core.interfaces.Numeric.Operator*. -
atimesb. -
atimesb. -
adivided byb.Doc from
std.core.interfaces.Numeric.Operator/. -
adivided byb. -
adivided byb. -
What's left of
a/bwith its quotient rounded toward 0, so it hasa's sign, exactly. A quotient of more digits than 28, or thanaorbhas when that's more, panics. -
What's left of
a/bwith its quotient rounded toward 0, so it hasa's sign, exactly. A quotient of more digits than 28, or thanaorbhas when that's more, panics. -
What's left of
a/bwith its quotient rounded toward 0, so it hasa's sign, exactly. A quotient of more digits than 28, or thanaorbhas when that's more, panics. -
To a whole power: anything to 0 is 1, and 0 to a power below 0 panics.
-
anegated.
Report an issue with this page or with FutureBlitz on GitHub.