aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryenlin.lai <yenlin.lai@cobinhood.com>2019-03-25 16:25:46 +0800
committeryenlinlai <38415072+yenlinlai@users.noreply.github.com>2019-03-29 10:50:26 +0800
commitaa8a495dd1acdcb6aac1fed13d2ed058cf3b5030 (patch)
tree2e5205ff0397436ec45106f63990dde1d17311fe
parent077dad5493da2935813e248241694f4a99837c3e (diff)
downloaddexon-decimal-aa8a495dd1acdcb6aac1fed13d2ed058cf3b5030.tar.gz
dexon-decimal-aa8a495dd1acdcb6aac1fed13d2ed058cf3b5030.tar.zst
dexon-decimal-aa8a495dd1acdcb6aac1fed13d2ed058cf3b5030.zip
misc: export rescale function
This will be useful when we are handling coefficients of decimals.
-rw-r--r--decimal.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/decimal.go b/decimal.go
index 0f7f18f..2b884d6 100644
--- a/decimal.go
+++ b/decimal.go
@@ -344,6 +344,14 @@ func NewFromFloatWithExponent(value float64, exp int32) Decimal {
}
}
+// Rescale returns a rescaled version of the decimal. Returned
+// decimal may be less precise if the given exponent is bigger
+// than the initial exponent of the Decimal.
+// NOTE: this will truncate, NOT round
+func (d Decimal) Rescale(exp int32) Decimal {
+ return d.rescale(exp)
+}
+
// rescale returns a rescaled version of the decimal. Returned
// decimal may be less precise if the given exponent is bigger
// than the initial exponent of the Decimal.