module std/num/decimalstd/num/decimal
import std/text/parsestd/text/parse
import std/num/float64std/num/float64
abstract value struct decimalstd/num/decimal/decimal: V
numstd/num/decimal/decimal/num: (decimal : decimal) -> int : intstd/core/types/int: V
expstd/num/decimal/decimal/exp: (decimal : decimal) -> int : intstd/core/types/int: V
pub val zerostd/num/decimal/zero: decimal : decimalstd/num/decimal/decimal: V = Decimalstd/num/decimal/Decimal: (num : int, exp : int) -> decimal(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000,0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000)
fun round-expstd/num/decimal/round-exp: (exp : int) -> int( expexp: int : intstd/core/types/int: V )result: -> total int : intstd/core/types/int: V
if expexp: int.is-zerostd/core/int/is-zero: (x : int) -> bool then 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 else 7literal: int
dec = 7
hex8 = 0x07
bit8 = 0b00000111*std/core/int/(*): (int, int) -> int(expexp: int /std/core/int/(/): (x : int, y : int) -> int 7literal: int
dec = 7
hex8 = 0x07
bit8 = 0b00000111)
pub fun int/decimalstd/num/decimal/int/decimal: (i : int, exp : ? int) -> decimal( ii: int : intstd/core/types/int: V, expexp: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 )result: -> total decimal : decimalstd/num/decimal/decimal: V
decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal(ii: int,expexp: int)
fun decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal( ii: int : intstd/core/types/int: V, expexp: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 )result: -> total decimal : decimalstd/num/decimal/decimal: V
val xx: int = round-expstd/num/decimal/round-exp: (exp : int) -> int(expexp: int) val diffdiff: int = expexp: int -std/core/int/(-): (x : int, y : int) -> int xx: int
if diffdiff: int.is-zerostd/core/int/is-zero: (x : int) -> bool then Decimalstd/num/decimal/Decimal: (num : int, exp : int) -> decimal(ii: int,expexp: int) else Decimalstd/num/decimal/Decimal: (num : int, exp : int) -> decimal(ii: int.mul-exp10std/core/int/mul-exp10: (i : int, n : int) -> int(diffdiff: int.absstd/core/int/abs: (i : int) -> int),xx: int)
pub fun float64/decimalstd/num/decimal/float64/decimal: (d : float64, max-prec : ? int) -> decimal( dd: float64 : float64std/core/types/float64: V, max-precmax-prec: ? int : intstd/core/types/int: V = -1literal: int
dec = -1
hex8 = 0xFF
bit8 = 0b11111111 )result: -> total decimal : decimalstd/num/decimal/decimal: V
val (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)manman: int,expexp: int)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) = dd: float64.decodestd/num/float64/decode: (d : float64) -> (int, int)
if expexp: int >=std/core/int/(>=): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 then (manman: int *std/core/int/(*): (int, int) -> int (2literal: int
dec = 2
hex8 = 0x02
bit8 = 0b00000010^std/core/int/(^): (i : int, exp : int) -> intexpexp: int)).decimalstd/num/decimal/int/decimal: (i : int, exp : ? int) -> decimal else
val precprec: int = if max-precmax-prec: int <std/core/int/(<): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 then ~std/core/int/(~): (i : int) -> intexpexp: int else minstd/core/int/min: (i : int, j : int) -> int(max-precmax-prec: int,~std/core/int/(~): (i : int) -> intexpexp: int)
divstd/num/decimal/div: (x : decimal, y : decimal, min-prec : ? int) -> decimal( manman: int.decimalstd/num/decimal/int/decimal: (i : int, exp : ? int) -> decimal, powstd/num/decimal/pow: (x : decimal, n : int) -> decimal(2literal: int
dec = 2
hex8 = 0x02
bit8 = 0b00000010.decimalstd/num/decimal/int/decimal: (i : int, exp : ? int) -> decimal, ~std/core/int/(~): (i : int) -> intexpexp: int), precprec: int )
pub fun parse-decimalstd/num/decimal/parse-decimal: (s : string) -> maybe<decimal>( ss: string : stringstd/core/types/string: V )result: -> total maybe<decimal> : maybestd/core/types/maybe: V -> V<decimalstd/num/decimal/decimal: V>
ss: string.trimstd/core/string/trim: (s : string) -> string.slicestd/core/sslice/slice: (s : string) -> sslice.parse-eofstd/text/parse/parse-eof: (input : sslice, p : () -> parse decimal) -> parse-error<decimal>(pdecimalstd/num/decimal/pdecimal: () -> parse decimal).maybestd/text/parse/maybe: (perr : parse-error<decimal>) -> maybe<decimal>
fun pdecimalstd/num/decimal/pdecimal: () -> parse decimal()result: -> parse decimal : parsestd/text/parse/parse: (E, V) -> V decimalstd/num/decimal/decimal: V
val negneg: bool = signstd/text/parse/sign: () -> parse bool()
val wholewhole: string = digitsstd/text/parse/digits: () -> parse string()
val fracfrac: string = optionalstd/text/parse/optional: (default : string, p : parser<total,string>) -> parse string(""literal: string
count= 0, { charstd/text/parse/char: (c : char) -> parse char('.'literal: char
unicode= u002E); digitsstd/text/parse/digits: () -> parse string() })
val expexp: int = optionalstd/text/parse/optional: (default : int, p : parser<total,int>) -> parse int(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000, { one-ofstd/text/parse/one-of: (chars : string) -> parse char("eE"literal: string
count= 2); pintstd/text/parse/pint: () -> parse int() })
val ii: decimal = decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> parse decimal( (wholewhole: string ++std/core/types/(++): (x : string, y : string) -> parse string fracfrac: string).parse-intstd/core/int/parse-int: (s : string, hex : ? bool) -> parse maybe<int>.defaultstd/core/maybe/default: (m : maybe<int>, nothing : int) -> parse int(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000), expexp: int -std/core/int/(-): (x : int, y : int) -> parse int fracfrac: string.countstd/core/string/count: (s : string) -> parse int )
if negneg: bool then ~std/num/decimal/(~): (x : decimal) -> parse decimalii: decimal else ii: decimal
fun expandstd/num/decimal/expand: (x : decimal, e : int) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, ee: int : intstd/core/types/int: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
if xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int <=std/core/int/(<=): (x : int, y : int) -> bool ee: int then xx: decimal else
decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal( xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.mul-exp10std/core/int/mul-exp10: (i : int, n : int) -> int( xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int -std/core/int/(-): (x : int, y : int) -> int ee: int ), ee: int )
pub fun reducestd/num/decimal/reduce: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
val pp: int = xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.is-exp10std/core/int/is-exp10: (i : int) -> int
if !std/core/types/bool/(!): (b : bool) -> boolpp: int.is-posstd/core/int/is-pos: (i : int) -> bool returnreturn: decimal xx: decimal
val exppexpp: int= xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int +std/core/int/(+): (x : int, y : int) -> int pp: int
if round-expstd/num/decimal/round-exp: (exp : int) -> int(exppexpp: int)==std/core/int/(==): (x : int, y : int) -> boolxx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int then xx: decimal else decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal(xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.cdiv-exp10std/core/int/cdiv-exp10: (i : int, n : int) -> int(pp: int), exppexpp: int)
pub fun (+)std/num/decimal/(+): (x : decimal, y : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
val ee: int = minstd/core/int/min: (i : int, j : int) -> int(xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int,yy: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int)
val xxxx: decimal = xx: decimal.expandstd/num/decimal/expand: (x : decimal, e : int) -> decimal(ee: int)
val yyyy: decimal = yy: decimal.expandstd/num/decimal/expand: (x : decimal, e : int) -> decimal(ee: int)
Decimalstd/num/decimal/Decimal: (num : int, exp : int) -> decimal(xxxx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int +std/core/int/(+): (x : int, y : int) -> int yyyy: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int, ee: int)
pub fun (~)std/num/decimal/(~): (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
Decimalstd/num/decimal/Decimal: (num : int, exp : int) -> decimal(~std/core/int/(~): (i : int) -> intxx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int, xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int)
pub fun (-)std/num/decimal/(-): (x : decimal, y : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
xx: decimal +std/num/decimal/(+): (x : decimal, y : decimal) -> decimal (~std/num/decimal/(~): (x : decimal) -> decimalyy: decimal)
pub fun incstd/num/decimal/inc: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
Decimalstd/num/decimal/Decimal: (num : int, exp : int) -> decimal(xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.incstd/core/int/inc: (i : int) -> int, xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int)
pub fun decstd/num/decimal/dec: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
Decimalstd/num/decimal/Decimal: (num : int, exp : int) -> decimal(xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.decstd/core/int/dec: (i : int) -> int, xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int)
pub fun is-evenstd/num/decimal/is-even: (x : decimal) -> bool(xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total bool : boolstd/core/types/bool: V
xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.is-evenstd/core/int/is-even: (i : int) -> bool
pub fun is-oddstd/num/decimal/is-odd: (x : decimal) -> bool( xx: decimal :decimalstd/num/decimal/decimal: V )result: -> total bool : boolstd/core/types/bool: V
xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.is-oddstd/core/int/is-odd: (i : int) -> bool
pub fun is-zerostd/num/decimal/is-zero: (x : decimal) -> bool( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total bool : boolstd/core/types/bool: V
xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.is-zerostd/core/int/is-zero: (x : int) -> bool
pub fun is-posstd/num/decimal/is-pos: (x : decimal) -> bool( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total bool : boolstd/core/types/bool: V
xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.is-posstd/core/int/is-pos: (i : int) -> bool
pub fun is-negstd/num/decimal/is-neg: (x : decimal) -> bool( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total bool : boolstd/core/types/bool: V
xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.is-negstd/core/int/is-neg: (i : int) -> bool
pub fun (*)std/num/decimal/(*): (x : decimal, y : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
val zz: decimal = decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal(xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int *std/core/int/(*): (int, int) -> int yy: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int, xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int +std/core/int/(+): (x : int, y : int) -> int yy: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int)
if zz: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int.is-negstd/core/int/is-neg: (i : int) -> bool then zz: decimal.reducestd/num/decimal/reduce: (x : decimal) -> decimal else zz: decimal
pub fun powstd/num/decimal/pow: (x : decimal, n : int) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, nn: int : intstd/core/types/int: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
val mm: int = nn: int.absstd/core/int/abs: (i : int) -> int
val yy: decimal = decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal(xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int ^std/core/int/(^): (i : int, exp : int) -> int mm: int, xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int *std/core/int/(*): (int, int) -> int mm: int )
if nn: int.is-negstd/core/int/is-neg: (i : int) -> bool then divstd/num/decimal/div: (x : decimal, y : decimal, min-prec : ? int) -> decimal( 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001.decimalstd/num/decimal/int/decimal: (i : int, exp : ? int) -> decimal, yy: decimal, 3literal: int
dec = 3
hex8 = 0x03
bit8 = 0b00000011 +std/core/int/(+): (x : int, y : int) -> int mm: int) else yy: decimal
pub type roundstd/num/decimal/round: V
con Half-evenstd/num/decimal/Half-even: round
con Half-ceilingstd/num/decimal/Half-ceiling: round
con Half-floorstd/num/decimal/Half-floor: round
con Half-truncatestd/num/decimal/Half-truncate: round
con Half-away-from-zerostd/num/decimal/Half-away-from-zero: round
con Ceilingstd/num/decimal/Ceiling: round
con Floorstd/num/decimal/Floor: round
con Truncatestd/num/decimal/Truncate: round
con Away-from-zerostd/num/decimal/Away-from-zero: round
pub fun intstd/num/decimal/int: (x : decimal, rnd : ? round) -> int( xx: decimal : decimalstd/num/decimal/decimal: V, rndrnd: ? round : roundstd/num/decimal/round: V = Half-evenstd/num/decimal/Half-even: round)result: -> total int : intstd/core/types/int: V
val yy: decimal = xx: decimal.roundstd/num/decimal/round: (x : decimal, rnd : ? round) -> decimal(rndrnd: round) if yy: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int.is-posstd/core/int/is-pos: (i : int) -> bool then yy: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.mul-exp10std/core/int/mul-exp10: (i : int, n : int) -> int(yy: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int) else yy: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int
pub fun roundstd/num/decimal/round: (x : decimal, rnd : ? round) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, rndrnd: ? round : roundstd/num/decimal/round: V = Half-evenstd/num/decimal/Half-even: round )result: -> total decimal : decimalstd/num/decimal/decimal: V
xx: decimal.round-to-precstd/num/decimal/round-to-prec: (x : decimal, prec : ? int, rnd : ? round) -> decimal(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000,rndrnd: round)
pub fun round-to-precstd/num/decimal/round-to-prec: (x : decimal, prec : ? int, rnd : ? round) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, precprec: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000, rndrnd: ? round : roundstd/num/decimal/round: V = Half-evenstd/num/decimal/Half-even: round )result: -> total decimal : totalstd/core/types/total: E decimalstd/num/decimal/decimal: V
if xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int >=std/core/int/(>=): (x : int, y : int) -> bool ~std/core/int/(~): (i : int) -> intprecprec: int returnreturn: decimal xx: decimal
val cxcx: decimal = xx: decimal.reducestd/num/decimal/reduce: (x : decimal) -> decimal
val pp: int = ~std/core/int/(~): (i : int) -> intcxcx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int -std/core/int/(-): (x : int, y : int) -> int precprec: int
if !std/core/types/bool/(!): (b : bool) -> boolpp: int.is-posstd/core/int/is-pos: (i : int) -> bool returnreturn: decimal cxcx: decimal
val (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)qq: int,rr: int)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) = cxcx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.divmod-exp10std/core/int/divmod-exp10: (i : int, n : int) -> (int, int)(pp: int)
fun round-halfround-half: (keep-on-eq : bool) -> int( keep-on-eqkeep-on-eq: bool : boolstd/core/types/bool: V )result: -> total int
val halfhalf: int = pp: int.exp10std/core/int/exp10: (exp : int) -> int /std/core/int/(/): (x : int, y : int) -> int 2literal: int
dec = 2
hex8 = 0x02
bit8 = 0b00000010
match cmpstd/core/int/cmp: (x : int, y : int) -> order(rr: int,halfhalf: int)
Eqstd/core/types/Eq: order -> if keep-on-eqkeep-on-eq: bool then qq: int else qq: int.incstd/core/int/inc: (i : int) -> int
Gtstd/core/types/Gt: order -> qq: int.incstd/core/int/inc: (i : int) -> int
Ltstd/core/types/Lt: order -> qq: int
val q1q1: int = if rr: int.is-zerostd/core/int/is-zero: (x : int) -> bool then qq: int else match rndrnd: round
Half-evenstd/num/decimal/Half-even: round -> round-halfround-half: (keep-on-eq : bool) -> int(qq: int.is-evenstd/core/int/is-even: (i : int) -> bool)
Half-floorstd/num/decimal/Half-floor: round -> round-halfround-half: (keep-on-eq : bool) -> int(Truestd/core/types/True: bool)
Half-ceilingstd/num/decimal/Half-ceiling: round -> round-halfround-half: (keep-on-eq : bool) -> int(Falsestd/core/types/False: bool)
Half-truncatestd/num/decimal/Half-truncate: round -> round-halfround-half: (keep-on-eq : bool) -> int(qq: int.is-posstd/core/int/is-pos: (i : int) -> bool)
Half-away-from-zerostd/num/decimal/Half-away-from-zero: round -> round-halfround-half: (keep-on-eq : bool) -> int(qq: int.is-negstd/core/int/is-neg: (i : int) -> bool)
Floorstd/num/decimal/Floor: round -> qq: int
Ceilingstd/num/decimal/Ceiling: round -> qq: int.incstd/core/int/inc: (i : int) -> int
Truncatestd/num/decimal/Truncate: round -> if !std/core/types/bool/(!): (b : bool) -> boolqq: int.is-negstd/core/int/is-neg: (i : int) -> bool then qq: int else qq: int.incstd/core/int/inc: (i : int) -> int
Away-from-zerostd/num/decimal/Away-from-zero: round -> if !std/core/types/bool/(!): (b : bool) -> boolqq: int.is-posstd/core/int/is-pos: (i : int) -> bool then qq: int else qq: int.incstd/core/int/inc: (i : int) -> int
decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal(q1q1: int,~std/core/int/(~): (i : int) -> intprecprec: int)
val maxexpstd/num/decimal/maxexp: int : intstd/core/types/int: V = 308literal: int
dec = 308
hex16= 0x0134
bit16= 0b0000000100110100
val maxpdstd/num/decimal/maxpd: float64 : float64std/core/types/float64: V = 1.0e15literal: float64
hex64= 0x1.c6bf52634p49
val maxprecisestd/num/decimal/maxprecise: int : intstd/core/types/int: V = intstd/num/float64/int: (f : float64) -> int(maxpdstd/num/decimal/maxpd: float64)
val minprecisestd/num/decimal/minprecise: int : intstd/core/types/int: V = ~std/core/int/(~): (i : int) -> intmaxprecisestd/num/decimal/maxprecise: int
fun is-precisestd/num/decimal/is-precise: (i : int) -> bool(ii: int : intstd/core/types/int: V )result: -> total bool : boolstd/core/types/bool: V
(ii: int >std/core/int/(>): (x : int, y : int) -> bool minprecisestd/num/decimal/minprecise: int &&std/core/types/(&&): (x : bool, y : bool) -> bool ii: int <std/core/int/(<): (x : int, y : int) -> bool maxprecisestd/num/decimal/maxprecise: int)
pub fun divstd/num/decimal/div: (x : decimal, y : decimal, min-prec : ? int) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V, min-precmin-prec: ? int : intstd/core/types/int: V = 15literal: int
dec = 15
hex8 = 0x0F
bit8 = 0b00001111 )result: -> total decimal : decimalstd/num/decimal/decimal: V
if xx: decimal.is-zerostd/num/decimal/is-zero: (x : decimal) -> bool ||std/core/types/(||): (x : bool, y : bool) -> bool yy: decimal.is-zerostd/num/decimal/is-zero: (x : decimal) -> bool then returnreturn: decimal Decimalstd/num/decimal/Decimal: (num : int, exp : int) -> decimal(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000,0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000)std/core/types/Unit: ()
val ee: int = xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int -std/core/int/(-): (x : int, y : int) -> int yy: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int
val xdigitsxdigits: int = xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.count-digitsstd/core/int/count-digits: (i : int) -> int
val ydigitsydigits: int = yy: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.count-digitsstd/core/int/count-digits: (i : int) -> int
val extraextra: int = maxstd/core/int/max: (i : int, j : int) -> int(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000,ydigitsydigits: int -std/core/int/(-): (x : int, y : int) -> int xdigitsxdigits: int) +std/core/int/(+): (x : int, y : int) -> int min-precmin-prec: int
if extraextra: int >std/core/int/(>): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
then decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal( xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.mul-exp10std/core/int/mul-exp10: (i : int, n : int) -> int(extraextra: int) /std/core/int/(/): (x : int, y : int) -> int yy: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int, ee: int -std/core/int/(-): (x : int, y : int) -> int extraextra: int ).reducestd/num/decimal/reduce: (x : decimal) -> decimal
else decimal-expstd/num/decimal/decimal-exp: (i : int, exp : ? int) -> decimal( xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int /std/core/int/(/): (x : int, y : int) -> int yy: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int, ee: int -std/core/int/(-): (x : int, y : int) -> int extraextra: int ).reducestd/num/decimal/reduce: (x : decimal) -> decimal
pub fun (/)std/num/decimal/(/): (x : decimal, y : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
divstd/num/decimal/div: (x : decimal, y : decimal, min-prec : ? int) -> decimal(xx: decimal,yy: decimal)
pub fun cmpstd/num/decimal/cmp: (x : decimal, y : decimal) -> order( xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V )result: -> total order : orderstd/core/types/order: V
val ee: int = minstd/core/int/min: (i : int, j : int) -> int(xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int,yy: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int)
val xxxx: decimal = xx: decimal.expandstd/num/decimal/expand: (x : decimal, e : int) -> decimal(ee: int)
val yyyy: decimal = yy: decimal.expandstd/num/decimal/expand: (x : decimal, e : int) -> decimal(ee: int)
cmpstd/core/int/cmp: (x : int, y : int) -> order(xxxx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int,yyyy: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int)
pub fun (>)std/num/decimal/(>): (x : decimal, y : decimal) -> bool (xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V)result: -> total bool : boolstd/core/types/bool: V { cmpstd/num/decimal/cmp: (x : decimal, y : decimal) -> order(xx: decimal,yy: decimal) ==std/core/order/(==): (x : order, y : order) -> bool Gtstd/core/types/Gt: order }
pub fun (>=)std/num/decimal/(>=): (x : decimal, y : decimal) -> bool(xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V)result: -> total bool : boolstd/core/types/bool: V { cmpstd/num/decimal/cmp: (x : decimal, y : decimal) -> order(xx: decimal,yy: decimal) !=std/core/order/(!=): (x : order, y : order) -> bool Ltstd/core/types/Lt: order }
pub fun (==)std/num/decimal/(==): (x : decimal, y : decimal) -> bool(xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V)result: -> total bool : boolstd/core/types/bool: V { cmpstd/num/decimal/cmp: (x : decimal, y : decimal) -> order(xx: decimal,yy: decimal) ==std/core/order/(==): (x : order, y : order) -> bool Eqstd/core/types/Eq: order }
pub fun (!=)std/num/decimal/(!=): (x : decimal, y : decimal) -> bool(xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V)result: -> total bool : boolstd/core/types/bool: V { cmpstd/num/decimal/cmp: (x : decimal, y : decimal) -> order(xx: decimal,yy: decimal) !=std/core/order/(!=): (x : order, y : order) -> bool Eqstd/core/types/Eq: order }
pub fun (<)std/num/decimal/(<): (x : decimal, y : decimal) -> bool (xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V)result: -> total bool : boolstd/core/types/bool: V { cmpstd/num/decimal/cmp: (x : decimal, y : decimal) -> order(xx: decimal,yy: decimal) ==std/core/order/(==): (x : order, y : order) -> bool Ltstd/core/types/Lt: order }
pub fun (<=)std/num/decimal/(<=): (x : decimal, y : decimal) -> bool(xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V)result: -> total bool : boolstd/core/types/bool: V { cmpstd/num/decimal/cmp: (x : decimal, y : decimal) -> order(xx: decimal,yy: decimal) !=std/core/order/(!=): (x : order, y : order) -> bool Gtstd/core/types/Gt: order }
pub fun signstd/num/decimal/sign: (x : decimal) -> order( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total order : orderstd/core/types/order: V
xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.signstd/core/int/sign: (i : int) -> order
pub fun minstd/num/decimal/min: (x : decimal, y : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
if xx: decimal <=std/num/decimal/(<=): (x : decimal, y : decimal) -> bool yy: decimal then xx: decimal else yy: decimal
pub fun maxstd/num/decimal/max: (x : decimal, y : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V, yy: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
if xx: decimal >=std/num/decimal/(>=): (x : decimal, y : decimal) -> bool yy: decimal then xx: decimal else yy: decimal
pub fun sumstd/num/decimal/sum: (ds : list<decimal>) -> decimal( dsds: list<decimal> : liststd/core/types/list: V -> V<decimalstd/num/decimal/decimal: V> )result: -> total decimal : decimalstd/num/decimal/decimal: V
dsds: list<decimal>.foldrstd/core/list/foldr: (xs : list<decimal>, z : decimal, f : (decimal, decimal) -> decimal) -> decimal(zerostd/num/decimal/zero: decimal,(+)std/num/decimal/(+): (x : decimal, y : decimal) -> decimal)
pub fun absstd/num/decimal/abs: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
if xx: decimal.is-negstd/num/decimal/is-neg: (x : decimal) -> bool then ~std/num/decimal/(~): (x : decimal) -> decimalxx: decimal else xx: decimal
pub fun floorstd/num/decimal/floor: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
xx: decimal.roundstd/num/decimal/round: (x : decimal, rnd : ? round) -> decimal(Floorstd/num/decimal/Floor: round)
pub fun ceilingstd/num/decimal/ceiling: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
xx: decimal.roundstd/num/decimal/round: (x : decimal, rnd : ? round) -> decimal(Ceilingstd/num/decimal/Ceiling: round)
pub fun truncatestd/num/decimal/truncate: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
xx: decimal.roundstd/num/decimal/round: (x : decimal, rnd : ? round) -> decimal(Truncatestd/num/decimal/Truncate: round)
pub fun float64std/num/decimal/float64: (x : decimal) -> float64( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total float64 : float64std/core/types/float64: V
if !std/core/types/bool/(!): (b : bool) -> boolxx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int.is-negstd/core/int/is-neg: (i : int) -> bool then
xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.float64std/num/float64/float64: (i : int) -> float64 *std/num/float64/(*): (x : float64, y : float64) -> float64 powstd/num/float64/pow: (d : float64, p : float64) -> float64(10.0literal: float64
hex64= 0x1.4p3,xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int.float64std/num/float64/float64: (i : int) -> float64)
else
val (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)qq: int,rr: int)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) = xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.divmod-exp10std/core/int/divmod-exp10: (i : int, n : int) -> (int, int)(~std/core/int/(~): (i : int) -> intxx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int)
qq: int.float64std/num/float64/float64: (i : int) -> float64 +std/num/float64/(+): (x : float64, y : float64) -> float64 rr: int.float64std/num/float64/float64: (i : int) -> float64 *std/num/float64/(*): (x : float64, y : float64) -> float64 exp10std/num/float64/exp10: (p : float64) -> float64(xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int.float64std/num/float64/float64: (i : int) -> float64)
pub fun fractionstd/num/decimal/fraction: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
if !std/core/types/bool/(!): (b : bool) -> boolxx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int.is-negstd/core/int/is-neg: (i : int) -> bool then zerostd/num/decimal/zero: decimal else (xx: decimal -std/num/decimal/(-): (x : decimal, y : decimal) -> decimal xx: decimal.truncatestd/num/decimal/truncate: (x : decimal) -> decimal)
pub fun ffractionstd/num/decimal/ffraction: (x : decimal) -> decimal( xx: decimal : decimalstd/num/decimal/decimal: V )result: -> total decimal : decimalstd/num/decimal/decimal: V
if !std/core/types/bool/(!): (b : bool) -> boolxx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int.is-negstd/core/int/is-neg: (i : int) -> bool then zerostd/num/decimal/zero: decimal else (xx: decimal -std/num/decimal/(-): (x : decimal, y : decimal) -> decimal xx: decimal.floorstd/num/decimal/floor: (x : decimal) -> decimal)
pub fun show-rawstd/num/decimal/show-raw: (d : decimal) -> string(dd: decimal : decimalstd/num/decimal/decimal: V)result: -> total string
dd: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.showstd/core/int/show: (i : int) -> string ++std/core/types/(++): (x : string, y : string) -> string "e"literal: string
count= 1 ++std/core/types/(++): (x : string, y : string) -> string dd: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int.showstd/core/int/show: (i : int) -> string
pub fun showstd/num/decimal/show: (d : decimal, prec : ? int) -> string( dd: decimal : decimalstd/num/decimal/decimal: V, precprec: ? int : intstd/core/types/int: V = -1000literal: int
dec = -1000
hex16= 0xFC18
bit16= 0b1111110000011000 )result: -> total string : stringstd/core/types/string: V
val expexp: int = dd: decimal.exponentstd/num/decimal/exponent: (d : decimal) -> int
if expexp: int >std/core/int/(>): (x : int, y : int) -> bool -5literal: int
dec = -5
hex8 = 0xFB
bit8 = 0b11111011 &&std/core/types/(&&): (x : bool, y : bool) -> bool expexp: int <std/core/int/(<): (x : int, y : int) -> bool (if precprec: int.is-negstd/core/int/is-neg: (i : int) -> bool then 15literal: int
dec = 15
hex8 = 0x0F
bit8 = 0b00001111 else precprec: int)
then show-fixedstd/num/decimal/show-fixed: (d : decimal, prec : ? int) -> string( dd: decimal, precprec: int )
else show-expstd/num/decimal/show-exp: (d : decimal, prec : ? int) -> string( dd: decimal, precprec: int )
pub fun exponentstd/num/decimal/exponent: (d : decimal) -> int( dd: decimal : decimalstd/num/decimal/decimal: V )result: -> total int : intstd/core/types/int: V
dd: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.count-digitsstd/core/int/count-digits: (i : int) -> int +std/core/int/(+): (x : int, y : int) -> int dd: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int -std/core/int/(-): (x : int, y : int) -> int 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
pub fun show-fixedstd/num/decimal/show-fixed: (d : decimal, prec : ? int) -> string( dd: decimal : decimalstd/num/decimal/decimal: V, precprec: ? int : intstd/core/types/int: V = -1000literal: int
dec = -1000
hex16= 0xFC18
bit16= 0b1111110000011000 )result: -> total string : stringstd/core/types/string: V
val xx: decimal = dd: decimal.round-to-precstd/num/decimal/round-to-prec: (x : decimal, prec : ? int, rnd : ? round) -> decimal(precprec: int.absstd/core/int/abs: (i : int) -> int)
if xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int >=std/core/int/(>=): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 then
val fracfrac: string = if precprec: int<=std/core/int/(<=): (x : int, y : int) -> bool0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 then ""literal: string
count= 0 else "."literal: string
count= 1 ++std/core/types/(++): (x : string, y : string) -> string repeatstd/core/string/repeat: (s : string, n : int) -> string("0"literal: string
count= 1,precprec: int)
xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.showstd/core/int/show: (i : int) -> string ++std/core/types/(++): (x : string, y : string) -> string repeatstd/core/string/repeat: (s : string, n : int) -> string("0"literal: string
count= 1,xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int) ++std/core/types/(++): (x : string, y : string) -> string fracfrac: string
else
val digitsdigits: int = ~std/core/int/(~): (i : int) -> intxx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int
val signsign: string = if xx: decimal.is-negstd/num/decimal/is-neg: (x : decimal) -> bool then "-"literal: string
count= 1 else ""literal: string
count= 0
val ii: int = xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.absstd/core/int/abs: (i : int) -> int
val manman: int = cdiv-exp10std/core/int/cdiv-exp10: (i : int, n : int) -> int(ii: int,digitsdigits: int)
val fracfrac: int = ii: int -std/core/int/(-): (x : int, y : int) -> int mul-exp10std/core/int/mul-exp10: (i : int, n : int) -> int(manman: int,digitsdigits: int)
signsign: string ++std/core/types/(++): (x : string, y : string) -> string manman: int.showstd/core/int/show: (i : int) -> string ++std/core/types/(++): (x : string, y : string) -> string fracfrac: int.showstd/core/int/show: (i : int) -> string.pad-leftstd/core/string/pad-left: (s : string, width : int, fill : ? char) -> string(digitsdigits: int,'0'literal: char
unicode= u0030).show-fracstd/num/decimal/show-frac: (frac : string, prec : int) -> string(precprec: int)
pub fun show-expstd/num/decimal/show-exp: (d : decimal, prec : ? int) -> string( dd: decimal : decimalstd/num/decimal/decimal: V, precprec: ? int : intstd/core/types/int: V = -1000literal: int
dec = -1000
hex16= 0xFC18
bit16= 0b1111110000011000 )result: -> total string : stringstd/core/types/string: V
val xx: decimal = dd: decimal.round-to-precstd/num/decimal/round-to-prec: (x : decimal, prec : ? int, rnd : ? round) -> decimal(precprec: int.absstd/core/int/abs: (i : int) -> int -std/core/int/(-): (x : int, y : int) -> int dd: decimal.exponentstd/num/decimal/exponent: (d : decimal) -> int)
val ss: string = xx: decimal.numstd/num/decimal/decimal/num: (decimal : decimal) -> int.absstd/core/int/abs: (i : int) -> int.showstd/core/int/show: (i : int) -> string
val digitsdigits: int = ss: string.countstd/core/string/count: (s : string) -> int
val expexp: int = xx: decimal.expstd/num/decimal/decimal/exp: (decimal : decimal) -> int +std/core/int/(+): (x : int, y : int) -> int digitsdigits: int -std/core/int/(-): (x : int, y : int) -> int 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
val signsign: string = if xx: decimal.is-negstd/num/decimal/is-neg: (x : decimal) -> bool then "-"literal: string
count= 1 else ""literal: string
count= 0
val exponentexponent: string = if expexp: int==std/core/int/(==): (x : int, y : int) -> bool0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 then ""literal: string
count= 0 else "e"literal: string
count= 1 ++std/core/types/(++): (x : string, y : string) -> string (if expexp: int.is-posstd/core/int/is-pos: (i : int) -> bool then "+"literal: string
count= 1 else ""literal: string
count= 0) ++std/core/types/(++): (x : string, y : string) -> string expexp: int.showstd/core/int/show: (i : int) -> string
signsign: string ++std/core/types/(++): (x : string, y : string) -> string ss: string.headstd/core/sslice/head: (s : string) -> string ++std/core/types/(++): (x : string, y : string) -> string ss: string.tailstd/core/sslice/tail: (s : string) -> string.show-fracstd/num/decimal/show-frac: (frac : string, prec : int) -> string(precprec: int) ++std/core/types/(++): (x : string, y : string) -> string exponentexponent: string
fun show-fracstd/num/decimal/show-frac: (frac : string, prec : int) -> string( fracfrac: string : stringstd/core/types/string: V, precprec: int : intstd/core/types/int: V )result: -> total string : stringstd/core/types/string: V
val frac-trimfrac-trim: string = fracfrac: string.trim-rightstd/core/sslice/trim-right: (s : string, sub : string) -> string("0"literal: string
count= 1)
val frac-fullfrac-full: string =if precprec: int >=std/core/int/(>=): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000 then frac-trimfrac-trim: string.pad-rightstd/core/string/pad-right: (s : string, width : int, fill : ? char) -> string(precprec: int,'0'literal: char
unicode= u0030) else frac-trimfrac-trim: string
if frac-fullfrac-full: string.is-emptystd/core/string/is-empty: (s : string) -> bool then ""literal: string
count= 0 else "."literal: string
count= 1 ++std/core/types/(++): (x : string, y : string) -> string frac-fullfrac-full: string