~/bend-docscommunity

f64.bend checks

raw source on the hub · import bend-kit-f64@0.1.1.0/f64.bend as F64

IEEE 754 binary64 add, sub, mul, and div. Source: https://github.com/paymog/bend-kit/tree/main/f64

1 import
import Base

Types

type W2 source · line 8 · raw

Data

type W4 source · line 11 · raw

Data

type Limb source · line 14 · raw

Data

type Step source · line 17 · raw

Data

type Cls source · line 20 · raw

Data

type Parts source · line 25 · raw

Data

type Norm source · line 28 · raw

Data

type F64 source · line 31 · raw

Data

type Dec source · line 1284 · raw

Data

Decimal text: d is the digits as one integer, nd counts digits from the first nonzero one, frac counts digits after the point, and seen counts all digits.

type Ex source · line 1287 · raw

Data

type St source · line 1444 · raw

Data

Burger and Dybvig's free-format digits: v = r / s, and the neighbours of v sit at (r - mm) / s and (r + mp) / s.

type Dig source · line 1447 · raw

Data

Definitions

def u01 source · line 34 · raw

@b:Bool -> U32

def clz.go source · line 41 · raw

@k:Nat -> @z:Bool -> @n:U32 -> @+x:U32 -> U32

def clz source · line 50 · raw

@+x:U32 -> U32

def F64.nan source · line 53 · raw

F64

def F64.inf.pos source · line 56 · raw

@pos:Bool -> F64

def F64.inf.sign source · line 63 · raw

@sign:U32 -> F64

def F64.zero.sign source · line 66 · raw

@sign:U32 -> F64

def F64.pack source · line 69 · raw

@sign:U32 -> @exp:U32 -> @sh:U32 -> @sl:U32 -> F64

def F64.hi source · line 72 · raw

@a:F64 -> U32

def F64.lo source · line 77 · raw

@a:F64 -> U32

def W2.nz source · line 82 · raw

@w:W2 -> Bool

def W2.bit.at source · line 87 · raw

@low:Bool -> @n:U32 -> @hi:U32 -> @lo:U32 -> U32

def W2.bit source · line 94 · raw

@w:W2 -> @+n:U32 -> U32

def W2.ge.eq source · line 99 · raw

@eq:Bool -> @al:U32 -> @bl:U32 -> Bool

def W2.ge.hi source · line 106 · raw

@gt:Bool -> @eq:Bool -> @al:U32 -> @bl:U32 -> Bool

def W2.ge source · line 113 · raw

@a:W2 -> @b:W2 -> Bool

def W2.sub.of source · line 118 · raw

@ah:U32 -> @bh:U32 -> @al:U32 -> @bl:U32 -> @lo:U32 -> W2

def W2.sub source · line 121 · raw

@a:W2 -> @b:W2 -> W2

def W2.shl1 source · line 126 · raw

@w:W2 -> @bit:U32 -> W2

def W2.shl.small source · line 131 · raw

@z:Bool -> @+k:U32 -> @hi:U32 -> @+lo:U32 -> W2

def W2.shl.big source · line 138 · raw

@big:Bool -> @+k:U32 -> @w:W2 -> W2

def W2.shl source · line 145 · raw

@w:W2 -> @+k:U32 -> W2

def W2.msb.hi source · line 148 · raw

@z:Bool -> @hi:U32 -> @lo:U32 -> U32

def W2.msb source · line 155 · raw

@w:W2 -> U32

def W2.inc.carry source · line 160 · raw

@z:Bool -> @hi:U32 -> @lo:U32 -> W2

def W2.inc.of source · line 167 · raw

@hi:U32 -> @+lo:U32 -> W2

def W2.inc source · line 170 · raw

@w:W2 -> W2

def W4.nz source · line 175 · raw

@w:W4 -> Bool

def W4.shl1 source · line 180 · raw

@w:W4 -> W4

def W4.set0 source · line 185 · raw

@w:W4 -> W4

def Limb.add.s source · line 190 · raw

@+x:U32 -> @c:U32 -> @+s1:U32 -> Limb

def Limb.add source · line 194 · raw

@+x:U32 -> @y:U32 -> @c:U32 -> Limb

def Limb.sub.s source · line 197 · raw

@x:U32 -> @y:U32 -> @+br:U32 -> @+s1:U32 -> Limb

def Limb.sub source · line 200 · raw

@+x:U32 -> @+y:U32 -> @br:U32 -> Limb

def W4.add.a source · line 203 · raw

@d:U32 -> @c:U32 -> @b:U32 -> @limb:Limb -> W4

def W4.add.b source · line 208 · raw

@xa:U32 -> @ya:U32 -> @d:U32 -> @c:U32 -> @limb:Limb -> W4

def W4.add.c source · line 213 · raw

@xa:U32 -> @xb:U32 -> @ya:U32 -> @yb:U32 -> @d:U32 -> @limb:Limb -> W4

def W4.add.d source · line 218 · raw

@xa:U32 -> @xb:U32 -> @xc:U32 -> @ya:U32 -> @yb:U32 -> @yc:U32 -> @limb:Limb -> W4

def W4.add source · line 223 · raw

@x:W4 -> @y:W4 -> W4

def W4.sub.a source · line 228 · raw

@d:U32 -> @c:U32 -> @b:U32 -> @limb:Limb -> W4

def W4.sub.b source · line 233 · raw

@xa:U32 -> @ya:U32 -> @d:U32 -> @c:U32 -> @limb:Limb -> W4

def W4.sub.c source · line 238 · raw

@xa:U32 -> @xb:U32 -> @ya:U32 -> @yb:U32 -> @d:U32 -> @limb:Limb -> W4

def W4.sub.d source · line 243 · raw

@xa:U32 -> @xb:U32 -> @xc:U32 -> @ya:U32 -> @yb:U32 -> @yc:U32 -> @limb:Limb -> W4

def W4.sub source · line 248 · raw

@x:W4 -> @y:W4 -> W4

def W4.one source · line 253 · raw

W4

def W4.drop1 source · line 256 · raw

@w:W4 -> Pair(W4, Bool)

def W4.drop2 source · line 261 · raw

@w:W4 -> Pair(W4, Bool)

def W4.drop3 source · line 266 · raw

@w:W4 -> Pair(W4, Bool)

def W4.shr.bits.out source · line 271 · raw

@+k:Nat -> @+j:Nat -> @+a:U32 -> @+b:U32 -> @+c:U32 -> @d:U32 -> @lost:Bool -> @low:U32 -> Pair(W4, Bool)

def W4.shr.bits.go source · line 274 · raw

@+k:Nat -> @j:Nat -> @w:W4 -> @lost:Bool -> Pair(W4, Bool)

def W4.shr.bits.z source · line 279 · raw

@z:Bool -> @+k:U32 -> @w:W4 -> @lost:Bool -> Pair(W4, Bool)

def W4.shr.bits source · line 286 · raw

@+k:U32 -> @w:W4 -> @lost:Bool -> Pair(W4, Bool)

def W4.shr.pair source · line 289 · raw

@bits:U32 -> @r:Pair(W4, Bool) -> Pair(W4, Bool)

def W4.shr.limbs source · line 293 · raw

@k:Nat -> @bits:U32 -> @w:W4 -> Pair(W4, Bool)

def W4.shr.wide source · line 306 · raw

@wide:Bool -> @+n:U32 -> @w:W4 -> Pair(W4, Bool)

def W4.shr source · line 313 · raw

@w:W4 -> @+n:U32 -> Pair(W4, Bool)

def W4.slide1 source · line 316 · raw

@w:W4 -> W4

def W4.slide2 source · line 321 · raw

@w:W4 -> W4

def W4.slide3 source · line 326 · raw

@w:W4 -> W4

def W4.shl.bits.go source · line 331 · raw

@+k:Nat -> @+j:Nat -> @w:W4 -> W4

def W4.shl.bits.z source · line 336 · raw

@z:Bool -> @+k:U32 -> @w:W4 -> W4

def W4.shl.bits source · line 343 · raw

@+k:U32 -> @w:W4 -> W4

def W4.shl.limbs source · line 346 · raw

@k:Nat -> @bits:U32 -> @w:W4 -> W4

def W4.shl.wide source · line 359 · raw

@wide:Bool -> @+n:U32 -> @w:W4 -> W4

def W4.shl source · line 366 · raw

@w:W4 -> @+n:U32 -> W4

def W4.msb.d source · line 369 · raw

@z:Bool -> @d:U32 -> Maybe<&2, U32>

def W4.msb.c source · line 376 · raw

@z:Bool -> @c:U32 -> @+d:U32 -> Maybe<&2, U32>

def W4.msb.b source · line 383 · raw

@z:Bool -> @b:U32 -> @+c:U32 -> @d:U32 -> Maybe<&2, U32>

def W4.msb.a source · line 390 · raw

@z:Bool -> @a:U32 -> @+b:U32 -> @c:U32 -> @d:U32 -> Maybe<&2, U32>

def W4.msb source · line 397 · raw

@w:W4 -> Maybe<&2, U32>

def mul32.of source · line 402 · raw

@+p00:U32 -> @+p01:U32 -> @+p10:U32 -> @+p11:U32 -> W2

def mul32 source · line 406 · raw

@+x:U32 -> @+y:U32 -> W2

def mul.sum6 source · line 413 · raw

@d:U32 -> @c:U32 -> @h11:U32 -> @b12:U32 -> @limb:Limb -> W4

def mul.sum5 source · line 418 · raw

@d:U32 -> @c:U32 -> @h11:U32 -> @+b:U32 -> @b12:U32 -> @carry:U32 -> W4

def mul.sum4 source · line 421 · raw

@d:U32 -> @c:U32 -> @h11:U32 -> @b1:U32 -> @carry:U32 -> @limb:Limb -> W4

def mul.sum3 source · line 426 · raw

@d:U32 -> @c:U32 -> @h10:U32 -> @h11:U32 -> @carry:U32 -> @limb:Limb -> W4

def mul.sum2 source · line 431 · raw

@d:U32 -> @c1:U32 -> @h01:U32 -> @h10:U32 -> @h11:U32 -> @l11:U32 -> @limb:Limb -> W4

def mul.sum1 source · line 436 · raw

@d:U32 -> @h01:U32 -> @l10:U32 -> @h10:U32 -> @h11:U32 -> @l11:U32 -> @limb:Limb -> W4

def mul.acc source · line 441 · raw

@p00:W2 -> @p01:W2 -> @p10:W2 -> @p11:W2 -> W4

def mul.wide source · line 446 · raw

@+xh:U32 -> @+xl:U32 -> @+yh:U32 -> @+yl:U32 -> W4

def div.bit.small source · line 449 · raw

@small:Bool -> @idx:U32 -> @ma:W2 -> U32

def div.bit source · line 456 · raw

@+p:Nat -> @ma:W2 -> U32

def div.ge source · line 459 · raw

@ge:Bool -> @rem:W2 -> @q:W4 -> @mb:W2 -> Step

def div.rem source · line 466 · raw

@+rem:W2 -> @q:W4 -> @+mb:W2 -> Step

def div.advance source · line 469 · raw

@p:Nat -> @st:Step -> @mb:W2 -> @ma:W2 -> Step

def div.finish source · line 474 · raw

@st:Step -> Pair(W4, Bool)

def div.go source · line 479 · raw

@k:Nat -> @st:Step -> @+mb:W2 -> @+ma:W2 -> Pair(W4, Bool)

def div.q source · line 487 · raw

@ma:W2 -> @mb:W2 -> Pair(W4, Bool)

def round.sub source · line 490 · raw

@sub:Bool -> @sign:U32 -> @exp:U32 -> @sh:U32 -> @sl:U32 -> F64

def round.zero.lo source · line 497 · raw

@zl:Bool -> @sign:U32 -> @exp:U32 -> @+sh:U32 -> @sl:U32 -> F64

def round.zero source · line 504 · raw

@zh:Bool -> @zl:Bool -> @sign:U32 -> @exp:U32 -> @+sh:U32 -> @sl:U32 -> F64

def round.inf source · line 511 · raw

@big:Bool -> @sign:U32 -> @exp:U32 -> @+sh:U32 -> @+sl:U32 -> F64

def round.pack source · line 518 · raw

@sign:U32 -> @+exp:U32 -> @sh:U32 -> @sl:U32 -> F64

def round.ov source · line 521 · raw

@ov:Bool -> @sign:U32 -> @exp:U32 -> @sh:U32 -> @sl:U32 -> F64

def round.inc source · line 528 · raw

@sign:U32 -> @exp:U32 -> @w:W2 -> F64

def round.should source · line 533 · raw

@+c:U32 -> @d:U32 -> @sl:U32 -> @sticky:Bool -> Bool

def round.up source · line 536 · raw

@up:Bool -> @sign:U32 -> @exp:U32 -> @sh:U32 -> @sl:U32 -> F64

def round.sig source · line 543 · raw

@sign:U32 -> @exp:U32 -> @sh:U32 -> @+sl:U32 -> @c:U32 -> @d:U32 -> @sticky:Bool -> F64

def round.go source · line 546 · raw

@sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.right.pair source · line 552 · raw

@sign:U32 -> @exp:U32 -> @sticky:Bool -> @r:Pair(W4, Bool) -> F64

def norm.right.sh source · line 556 · raw

@+sh:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.right source · line 559 · raw

@top:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.left.room0 source · line 562 · raw

@z:Bool -> @room:U32 -> @sign:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.left.fit source · line 569 · raw

@fit:Bool -> @+need:U32 -> @+room:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.left.room source · line 576 · raw

@+need:U32 -> @+room:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.left.need source · line 579 · raw

@need:U32 -> @sign:U32 -> @+exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.left source · line 582 · raw

@top:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.lo source · line 585 · raw

@lo:Bool -> @top:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.hi source · line 592 · raw

@hi:Bool -> @+top:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.top source · line 598 · raw

@m:Maybe<&2, U32> -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def norm.z source · line 605 · raw

@nz:Bool -> @sign:U32 -> @exp:U32 -> @+w:W4 -> @sticky:Bool -> F64

def norm.go source · line 612 · raw

@st:Norm -> F64

def under.pair source · line 617 · raw

@sign:U32 -> @sticky:Bool -> @r:Pair(W4, Bool) -> F64

def under.shr source · line 621 · raw

@sign:U32 -> @w:W4 -> @sticky:Bool -> @sh:U32 -> F64

def under.low source · line 624 · raw

@low:Bool -> @exp:U32 -> @sign:U32 -> @w:W4 -> @sticky:Bool -> F64

def under source · line 631 · raw

@sign:U32 -> @+exp:U32 -> @w:W4 -> @sticky:Bool -> F64

def mag.eq source · line 634 · raw

@eq:Bool -> @al:U32 -> @bl:U32 -> Bool

def mag.hi source · line 641 · raw

@lt:Bool -> @eq:Bool -> @al:U32 -> @bl:U32 -> Bool

def mag.same source · line 648 · raw

@eq:Bool -> @ma:W2 -> @mb:W2 -> Bool

def mag.exp source · line 655 · raw

@lt:Bool -> @eq:Bool -> @ma:W2 -> @mb:W2 -> Bool

def mag.lt source · line 662 · raw

@+ea:U32 -> @ma:W2 -> @+eb:U32 -> @mb:W2 -> Bool

def add.cancel source · line 665 · raw

@nz:Bool -> @sign:U32 -> @exp:U32 -> @total:W4 -> @sticky:Bool -> F64

def add.borrow source · line 672 · raw

@sign:U32 -> @exp:U32 -> @+total:W4 -> F64

def add.sub.lost source · line 675 · raw

@lost:Bool -> @sign:U32 -> @exp:U32 -> @+total:W4 -> F64

def add.sign source · line 682 · raw

@same:Bool -> @sign:U32 -> @exp:U32 -> @+aa:W4 -> @+trunc:W4 -> @lost:Bool -> F64

def add.pair source · line 689 · raw

@same:Bool -> @sign:U32 -> @exp:U32 -> @aa:W4 -> @r:Pair(W4, Bool) -> F64

def add.de source · line 693 · raw

@same:Bool -> @sa:U32 -> @ea:U32 -> @ma:W2 -> @de:U32 -> @mb:W2 -> F64

def add.ord source · line 697 · raw

@swap:Bool -> @+sa:U32 -> @+ea:U32 -> @+ma:W2 -> @+sb:U32 -> @+eb:U32 -> @+mb:W2 -> F64

def add.fin source · line 705 · raw

@+sa:U32 -> @+ea:U32 -> @+ma:W2 -> @+sb:U32 -> @+eb:U32 -> @+mb:W2 -> F64

def add.fin.z source · line 708 · raw

@na:Bool -> @nb:Bool -> @a:F64 -> @b:F64 -> @+sa:U32 -> @ea:U32 -> @ma:W2 -> @sb:U32 -> @eb:U32 -> @mb:W2 -> F64

def add.kb source · line 719 · raw

@kb:Cls -> @a:F64 -> @b:F64 -> @sa:U32 -> @ea:U32 -> @+ma:W2 -> @sb:U32 -> @eb:U32 -> @+mb:W2 -> F64

def add.inf.both source · line 728 · raw

@same:Bool -> @sa:U32 -> F64

def add.inf.a source · line 735 · raw

@kb:Cls -> @+sa:U32 -> @sb:U32 -> F64

def add.ka source · line 744 · raw

@ka:Cls -> @kb:Cls -> @a:F64 -> @b:F64 -> @sa:U32 -> @ea:U32 -> @ma:W2 -> @sb:U32 -> @eb:U32 -> @mb:W2 -> F64

def add.both source · line 753 · raw

@a:F64 -> @b:F64 -> @pa:Parts -> @pb:Parts -> F64

def unpack.sub source · line 758 · raw

@sub:Bool -> @exp:U32 -> @+h:U32 -> @l:U32 -> Parts

def unpack.nan source · line 765 · raw

@z:Bool -> @h:U32 -> Parts

def unpack.special source · line 772 · raw

@naninf:Bool -> @sub:Bool -> @exp:U32 -> @+h:U32 -> @l:U32 -> Parts

def unpack source · line 779 · raw

@+h:U32 -> @l:U32 -> Parts

def F64.add source · line 782 · raw

@a:F64 -> @b:F64 -> F64

def F64.neg source · line 787 · raw

@a:F64 -> F64

def F64.sub source · line 792 · raw

@a:F64 -> @b:F64 -> F64

def mul.sig source · line 795 · raw

@sa:U32 -> @ea:U32 -> @ma:W2 -> @sb:U32 -> @eb:U32 -> @mb:W2 -> F64

def mul.z source · line 800 · raw

@az:Bool -> @bz:Bool -> @sign:U32 -> @sa:U32 -> @ea:U32 -> @ma:W2 -> @sb:U32 -> @eb:U32 -> @mb:W2 -> F64

def Cls.inf source · line 809 · raw

@k:Cls -> Bool

def Cls.fin source · line 818 · raw

@k:Cls -> Bool

def Cls.nan source · line 827 · raw

@k:Cls -> Bool

def mul.inf.z source · line 836 · raw

@z:Bool -> @sign:U32 -> F64

def mul.inf source · line 843 · raw

@inf:Bool -> @az:Bool -> @bz:Bool -> @sign:U32 -> @sa:U32 -> @ea:U32 -> @ma:W2 -> @sb:U32 -> @eb:U32 -> @mb:W2 -> F64

def mul.nan source · line 850 · raw

@nan:Bool -> @+ca:Cls -> @+cb:Cls -> @+sa:U32 -> @ea:U32 -> @+ma:W2 -> @+sb:U32 -> @eb:U32 -> @+mb:W2 -> F64

def mul.parts source · line 857 · raw

@pa:Parts -> @pb:Parts -> F64

def F64.mul source · line 862 · raw

@a:F64 -> @b:F64 -> F64

def div.norm source · line 867 · raw

@k:U32 -> @mb:W2 -> W2

def div.sig.q source · line 870 · raw

@sign:U32 -> @exp:U32 -> @r:Pair(W4, Bool) -> F64

def div.sig source · line 874 · raw

@sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> @+k:U32 -> F64

def div.k source · line 877 · raw

@sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @+mb:W2 -> F64

def div.by0 source · line 880 · raw

@na:Bool -> @sign:U32 -> F64

def div.num0 source · line 887 · raw

@na:Bool -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64

def div.fin.z source · line 894 · raw

@nb:Bool -> @na:Bool -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64

def div.fin.a source · line 901 · raw

@ia:Bool -> @nb:Bool -> @na:Bool -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64

def div.fin.b source · line 908 · raw

@ib:Bool -> @ia:Bool -> @nb:Bool -> @na:Bool -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64

def div.fin source · line 915 · raw

@+ca:Cls -> @+cb:Cls -> @sign:U32 -> @ea:U32 -> @+ma:W2 -> @eb:U32 -> @+mb:W2 -> F64

def div.both source · line 918 · raw

@both:Bool -> @ca:Cls -> @cb:Cls -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64

def div.nan source · line 925 · raw

@nan:Bool -> @both:Bool -> @ca:Cls -> @cb:Cls -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64

def div.parts source · line 932 · raw

@pa:Parts -> @pb:Parts -> F64

def F64.div source · line 937 · raw

@a:F64 -> @b:F64 -> F64

def F64.nan.bits source · line 942 · raw

@+h:U32 -> @l:U32 -> Bool

def F64.zero.bits source · line 945 · raw

@h:U32 -> @l:U32 -> Bool

def F64.is_nan source · line 948 · raw

@a:F64 -> Bool

def F64.is_inf source · line 953 · raw

@a:F64 -> Bool

def F64.is_zero source · line 958 · raw

@a:F64 -> Bool

def F64.is_subnormal source · line 963 · raw

@a:F64 -> Bool

def F64.eq.bits source · line 968 · raw

@ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool

def F64.eq.zb source · line 971 · raw

@zb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool

def F64.eq.zero source · line 978 · raw

@za:Bool -> @zb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool

def F64.eq.nb source · line 985 · raw

@nb:Bool -> @+ah:U32 -> @+al:U32 -> @+bh:U32 -> @+bl:U32 -> Bool

def F64.eq.nan source · line 992 · raw

@na:Bool -> @nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool

def F64.is_eq source · line 999 · raw

@a:F64 -> @b:F64 -> Bool

def F64.lt.eq source · line 1004 · raw

@eq:Bool -> @al:U32 -> @bl:U32 -> Bool

def F64.lt.hi source · line 1011 · raw

@lt:Bool -> @eq:Bool -> @al:U32 -> @bl:U32 -> Bool

def F64.lt.mag source · line 1018 · raw

@+ah:U32 -> @al:U32 -> @+bh:U32 -> @bl:U32 -> Bool

def F64.lt.neg source · line 1021 · raw

@nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool

def F64.lt.pos source · line 1028 · raw

@nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool

def F64.lt.sign source · line 1035 · raw

@na:Bool -> @nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool

def F64.lt.zb source · line 1042 · raw

@zb:Bool -> @+ah:U32 -> @al:U32 -> @+bh:U32 -> @bl:U32 -> Bool

def F64.lt.zero source · line 1049 · raw

@za:Bool -> @zb:Bool -> @+ah:U32 -> @al:U32 -> @+bh:U32 -> @bl:U32 -> Bool

def F64.lt.nb source · line 1056 · raw

@nb:Bool -> @+ah:U32 -> @+al:U32 -> @+bh:U32 -> @+bl:U32 -> Bool

def F64.lt.nan source · line 1063 · raw

@na:Bool -> @nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool

def F64.is_lt source · line 1070 · raw

@a:F64 -> @b:F64 -> Bool

def F64.is_ne source · line 1075 · raw

@a:F64 -> @b:F64 -> Bool

def F64.is_le source · line 1078 · raw

@+a:F64 -> @+b:F64 -> Bool

def F64.is_gt source · line 1081 · raw

@a:F64 -> @b:F64 -> Bool

def F64.is_ge source · line 1084 · raw

@+a:F64 -> @+b:F64 -> Bool

def F64.abs source · line 1087 · raw

@a:F64 -> F64

def F64.from.lo source · line 1092 · raw

@+z:U32 -> @+n:U32 -> @hi_sh:U32 -> @lo_sh:U32 -> F64

def F64.from.small source · line 1095 · raw

@small:Bool -> @+z:U32 -> @+n:U32 -> F64

def F64.from.clz source · line 1102 · raw

@+z:U32 -> @n:U32 -> F64

def F64.from.z source · line 1105 · raw

@z:Bool -> @+n:U32 -> F64

def F64.from_u32 source · line 1112 · raw

@+n:U32 -> F64

def F64.one source · line 1115 · raw

F64

def F64.zero source · line 1118 · raw

F64

def F64.inf source · line 1121 · raw

F64

def Txt.if source · line 1125 · raw

@-A:Type -> @c:Bool -> @t:(@_:Unit -> A) -> @e:(@_:Unit -> A) -> A

A match cannot scrutinize a computed Bool, so each branch is a closure.

def Big.lone source · line 1133 · raw

@z:Bool -> @x:U32 -> List<&2, U32>

A Big is a natural number in base-2^16 limbs, least significant first, with no zero limb on top.

def Big.cons source · line 1140 · raw

@+x:U32 -> @r:List<&2, U32> -> List<&2, U32>

def Big.norm source · line 1147 · raw

@xs:List<&2, U32> -> List<&2, U32>

def Big.mul1 source · line 1155 · raw

@a:List<&2, U32> -> @+m:U32 -> @+c:U32 -> List<&2, U32>

a * m + c for m at most 2^16 and c below 2^16.

def Big.inc source · line 1163 · raw

@a:List<&2, U32> -> @z:Bool -> @+c:U32 -> List<&2, U32>

def Big.add source · line 1174 · raw

@a:List<&2, U32> -> @b:List<&2, U32> -> @+c:U32 -> List<&2, U32>

def Big.dec source · line 1184 · raw

@a:List<&2, U32> -> @z:Bool -> @+w:U32 -> List<&2, U32>

def Big.sub source · line 1196 · raw

@a:List<&2, U32> -> @b:List<&2, U32> -> @+w:U32 -> List<&2, U32>

a - b - w for a >= b + w. Callers norm the result.

def Big.then source · line 1206 · raw

@hi:Cmp -> @lo:Cmp -> Cmp

def Big.cmp source · line 1215 · raw

@a:List<&2, U32> -> @b:List<&2, U32> -> Cmp

def Big.zeros source · line 1226 · raw

@n:Nat -> @xs:List<&2, U32> -> List<&2, U32>

def Big.shl source · line 1233 · raw

@xs:List<&2, U32> -> @+k:U32 -> List<&2, U32>

def Big.top source · line 1240 · raw

@xs:List<&2, U32> -> U32

def Big.bits source · line 1244 · raw

@+xs:List<&2, U32> -> U32

The bit length of a nonzero Big.

def Big.times source · line 1247 · raw

@n:Nat -> @+m:U32 -> @a:List<&2, U32> -> List<&2, U32>

def Big.any source · line 1254 · raw

@xs:List<&2, U32> -> Bool

def Big.w4 source · line 1262 · raw

@xs:List<&2, U32> -> W4

The low 128 bits as a W4.

def Big.digit source · line 1270 · raw

@f:Nat -> @ge:Bool -> @+q:U32 -> @+t:List<&2, U32> -> @+s:List<&2, U32> -> Pair(U32, List<&2, U32>)

(q + t / s, t % s) for t < 10 s, by repeated subtraction.

def Rd.is_digit source · line 1290 · raw

@+c:U32 -> Bool

def Dec.push source · line 1293 · raw

@infrac:Bool -> @+v:U32 -> @acc:Dec -> Dec

def Rd.digits source · line 1298 · raw

@s:String -> @+infrac:Bool -> @+acc:Dec -> Pair(String, Dec)

def Rd.expo source · line 1308 · raw

@s:String -> @+n:U32 -> @+any:Bool -> Ex

The exponent saturates at 999999, far past any finite double.

def Rd.lower source · line 1317 · raw

@s:String -> String

def Rd.empty source · line 1324 · raw

@s:String -> Bool

def Rd.pos.cut source · line 1332 · raw

@sign:U32 -> @+n:List<&2, U32> -> @+e:U32 -> @+dr:U32 -> F64

value = d * 2^e for a nonzero d; only the top 8 limbs reach the rounding.

def Rd.pos source · line 1335 · raw

@sign:U32 -> @+n:List<&2, U32> -> @e:U32 -> F64

def Div.go source · line 1340 · raw

@f:Nat -> @+vv:List<&2, U32> -> @+u:List<&2, U32> -> @+q:W4 -> Pair(W4, Bool)

Restoring division with u = r * 2^i against vv = v * 2^67: 68 quotient bits, then the sticky remainder.

def Rd.div.q source · line 1350 · raw

@sign:U32 -> @x:U32 -> @r:Pair(W4, Bool) -> F64

def Rd.div source · line 1354 · raw

@sign:U32 -> @x:U32 -> @num:List<&2, U32> -> @den:List<&2, U32> -> F64

def Rd.neg.go source · line 1359 · raw

@+sign:U32 -> @+d:List<&2, U32> -> @+s:List<&2, U32> -> @+m:U32 -> @+bd:U32 -> @+bs:U32 -> F64

value = d / s * 2^-m with s = 5^m. Shift one side so num has 66 more bits than den; the quotient then has 65 to 67 bits.

def Rd.neg.s source · line 1364 · raw

@sign:U32 -> @+d:List<&2, U32> -> @+s:List<&2, U32> -> @m:U32 -> F64

def Rd.neg source · line 1367 · raw

@sign:U32 -> @d:List<&2, U32> -> @+m:U32 -> F64

def Rd.value source · line 1371 · raw

@+sign:U32 -> @+d:List<&2, U32> -> @nd:U32 -> @+eb:U32 -> F64

eb is the decimal exponent plus 2^30. A value under 10^-324 reads as zero, and one at or over 10^310 as infinity.

def Rd.done.eb source · line 1380 · raw

@neg:Bool -> @+n:U32 -> @+frac:U32 -> U32

def Rd.done source · line 1387 · raw

@sign:U32 -> @a:Dec -> @neg:Bool -> @n:U32 -> Maybe<&2, F64>

def Rd.eend source · line 1393 · raw

@sign:U32 -> @a:Dec -> @neg:Bool -> @ex:Ex -> Maybe<&2, F64>

def Rd.esign source · line 1398 · raw

@+sign:U32 -> @+a:Dec -> @s:String -> Maybe<&2, F64>

def Rd.exp source · line 1407 · raw

@sign:U32 -> @r:String -> @a:Dec -> Maybe<&2, F64>

def Rd.frac source · line 1414 · raw

@sign:U32 -> @p:Pair(String, Dec) -> Maybe<&2, F64>

def Rd.dot source · line 1418 · raw

@+sign:U32 -> @p:Pair(String, Dec) -> Maybe<&2, F64>

def Rd.body source · line 1427 · raw

@+sign:U32 -> @+s:String -> Maybe<&2, F64>

def F64.read source · line 1435 · raw

@s:String -> Maybe<&2, F64>

Decimal text to the nearest double, ties to even: [+-]digits[.digits][(e|E)[+-]digits], with digits on at least one side of the point, or inf, infinity, or nan in any case.

def Sh.high source · line 1452 · raw

@even:Bool -> @r:List<&2, U32> -> @mp:List<&2, U32> -> @s:List<&2, U32> -> Bool

An even mantissa reads back from either bound, so the bounds count.

def Sh.low source · line 1459 · raw

@even:Bool -> @r:List<&2, U32> -> @mm:List<&2, U32> -> Bool

def Sh.near source · line 1467 · raw

@c:Cmp -> @+d:U32 -> U32

A tie rounds to the even digit.

def Sh.pick source · line 1476 · raw

@tc1:Bool -> @tc2:Bool -> @+d:U32 -> @+r:List<&2, U32> -> @+s:List<&2, U32> -> @mp:List<&2, U32> -> @mm:List<&2, U32> -> Dig

def Sh.digit.fin source · line 1491 · raw

@+even:Bool -> @qr:Pair(U32, List<&2, U32>) -> @+s:List<&2, U32> -> @+mp:List<&2, U32> -> @+mm:List<&2, U32> -> Dig

def Sh.digit source · line 1496 · raw

@+even:Bool -> @st:St -> Dig

def Sh.gen source · line 1502 · raw

@f:Nat -> @+even:Bool -> @o:Dig -> List<&2, U32>

def Sh.up source · line 1514 · raw

@f:Nat -> @+even:Bool -> @big:Bool -> @st:St -> @+k:U32 -> Pair(St, U32)

k is the decimal exponent plus 400: v = 0.d1d2... * 10^(k - 400).

def Sh.down source · line 1528 · raw

@f:Nat -> @+even:Bool -> @small:Bool -> @st:St -> @+k:U32 -> Pair(St, U32)

def Sh.fix.down source · line 1543 · raw

@+even:Bool -> @sk:Pair(St, U32) -> Pair(St, U32)

def Sh.fix source · line 1550 · raw

@+even:Bool -> @st:St -> @+k:U32 -> Pair(St, U32)

k starts from an estimate of floor(log10 v) + 1 that is at most 2 off.

def Sh.scale source · line 1555 · raw

@pos:Bool -> @+n:Nat -> @st:St -> St

def Sh.chars source · line 1562 · raw

@ds:List<&2, U32> -> String

def Sh.fill source · line 1569 · raw

@n:Nat -> String

def Sh.exp.if source · line 1576 · raw

@small:Bool -> @+e:U32 -> String

def Sh.exp source · line 1583 · raw

@neg:Bool -> @+e:U32 -> String

def Sh.frac source · line 1590 · raw

@ds:String -> String

def Sh.sci source · line 1597 · raw

@ds:String -> @+k:U32 -> String

def Sh.fixed.big source · line 1604 · raw

@ge:Bool -> @+ds:String -> @+kn:Nat -> String

def Sh.fixed source · line 1611 · raw

@pos:Bool -> @+ds:String -> @+k:U32 -> String

def Sh.show.if source · line 1619 · raw

@sci:Bool -> @+ds:String -> @+k:U32 -> String

def Sh.fin source · line 1627 · raw

@+even:Bool -> @sk:Pair(St, U32) -> String

Like Python's repr: plain from 1e-4 up to 1e16, scientific outside.

def Sh.finite.go source · line 1632 · raw

@+f:List<&2, U32> -> @+be:U32 -> @+t:U32 -> @+even:Bool -> String

v = f * 2^(be - 1075). A power-of-two f above the least exponent has a nearer lower neighbour, so t = 1 there.

def Sh.finite source · line 1640 · raw

@+ex:U32 -> @+mh:U32 -> @+lo:U32 -> String

def Sh.sign source · line 1645 · raw

@neg:Bool -> @s:String -> String

def Sh.go source · line 1652 · raw

@naninf:Bool -> @zero:Bool -> @+neg:Bool -> @+ex:U32 -> @+mh:U32 -> @+lo:U32 -> String

def F64.show source · line 1664 · raw

@x:F64 -> String

The shortest decimal that reads back to x, like Python's repr: "1.0", "0.1", "1e+16", "5e-324", "inf", "nan".