Module DA.BigNumeric¶
This module exposes operations for working with the BigNumeric type.
Functions¶
- scale
- : BigNumeric -> Int - Calculate the scale of a - BigNumericnumber. The- BigNumericnumber is represented as- n * 10^-swhere- nis an integer with no trailing zeros, and- sis the scale.- Thus, the scale represents the number of nonzero digits after the decimal point. Note that the scale can be negative if the - BigNumericrepresents an integer with trailing zeros. In that case, it represents the number of trailing zeros (negated).- The scale ranges between 2^15 and -2^15 + 1. The scale of - 0is- 0by convention.- >>> scale 1.1 1 - >>> scale (shiftLeft (2^14) 1.0) -2^14 
- precision
- : BigNumeric -> Int - Calculate the precision of a - BigNumericnumber. The- BigNumericnumber is represented as- n * 10^-swhere- nis an integer with no trailing zeros, and- sis the scale. The precision is the number of digits in- n.- Thus, the precision represents the number of significant digits in the - BigNumeric.- The precision ranges between 0 and 2^16 - 1. - >>> precision 1.10 2 
- div
- : Int -> RoundingMode -> BigNumeric -> BigNumeric -> BigNumeric - Calculate a division of - BigNumericnumbers. The value of- div n r a bis the division of- aby- b, rounded to- ndecimal places (i.e. scale), according to the rounding mode- r.- This will fail when dividing by - 0, and when using the- RoundingUnnecessarymode for a number that cannot be represented exactly with at most- ndecimal places.
- round
- : Int -> RoundingMode -> BigNumeric -> BigNumeric - Round a - BigNumericnumber. The value of- round n r ais the value of- arounded to- ndecimal places (i.e. scale), according to the rounding mode- r.- This will fail when using the - RoundingUnnecessarymode for a number that cannot be represented exactly with at most- ndecimal places.
- shiftRight
- : Int -> BigNumeric -> BigNumeric - Shift a - BigNumericnumber to the right by a power of 10. The value- shiftRight n ais the value of- atimes- 10^(-n).- This will fail if the resulting - BigNumericis out of bounds.- >>> shiftRight 2 32.0 0.32 
- shiftLeft
- : Int -> BigNumeric -> BigNumeric - Shift a - BigNumericnumber to the left by a power of 10. The value- shiftLeft n ais the value of- atimes- 10^n.- This will fail if the resulting - BigNumericis out of bounds.- >>> shiftLeft 2 32.0 3200.0 
- roundToNumeric
- : NumericScale n => RoundingMode -> BigNumeric -> Numeric n - Round a - BigNumericand cast it to a- Numeric. This function uses the scale of the resulting numeric to determine the scale of the rounding.- This will fail when using the - RoundingUnnecessarymode if the- BigNumericcannot be represented exactly in the requested- Numeric n.- >>> (roundToNumeric RoundingHalfUp 1.23456789 : Numeric 5) 1.23457