f64.bend checks
raw source on the hub · import bend-kit-f64@0.1.4.0/f64.bend as F64
IEEE 754 binary64 arithmetic and square root. Source: https://github.com/paymog/bend-kit/tree/main/f64
2 imports
import Base import ./powers.bend as Pow
Types
type W2 source · line 9 · raw
Data
W2@hi:U32 -> @lo:U32 -> W2
type W4 source · line 12 · raw
Data
W4@a:U32 -> @b:U32 -> @c:U32 -> @d:U32 -> W4
type Limb source · line 15 · raw
Data
Limb@s:U32 -> @c:U32 -> Limb
type Step source · line 18 · raw
Data
Step@rem:W2 -> @q:W4 -> Step
type Cls source · line 21 · raw
Data
FinCls
InfCls
NanCls
type Parts source · line 26 · raw
Data
Parts@kind:Cls -> @sign:U32 -> @exp:U32 -> @sig:W2 -> Parts
type Norm source · line 29 · raw
Data
Norm@sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> Norm
type F64 source · line 32 · raw
Data
F64@hi:U32 -> @lo:U32 -> F64
type SqrtStep source · line 943 · raw
Data
SqrtStep@rem:W2 -> @root:W2 -> SqrtStep
type Dec source · line 1439 · 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.
Dec@d:List<&2, U32> -> @nd:U32 -> @frac:U32 -> @seen:U32 -> Dec
type Ex source · line 1442 · raw
Data
Ex@rest:String -> @n:U32 -> @any:Bool -> Ex
type Cached source · line 1526 · raw
Data
Cached-power intervals follow Grisu and Eisel-Lemire; ambiguous intervals use exact integers.
Cached@w:W4 -> @exact:Bool -> Cached
type St source · line 1659 · 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.
St@r:List<&2, U32> -> @s:List<&2, U32> -> @mp:List<&2, U32> -> @mm:List<&2, U32> -> St
type Dig source · line 1662 · raw
Data
More@d:U32 -> @st:St -> Dig
Last@d:U32 -> Dig
type Floor source · line 1846 · raw
Data
Floor@w:W4 -> @exact:Bool -> Floor
Definitions
def u01 source · line 35 · raw
@b:Bool -> U32
def clz.go source · line 42 · raw
@k:Nat -> @z:Bool -> @n:U32 -> @+x:U32 -> U32
def clz source · line 51 · raw
@+x:U32 -> U32
def F64.nan source · line 54 · raw
F64
def F64.inf.pos source · line 57 · raw
@pos:Bool -> F64
def F64.inf.sign source · line 64 · raw
@sign:U32 -> F64
def F64.zero.sign source · line 67 · raw
@sign:U32 -> F64
def F64.pack source · line 70 · raw
@sign:U32 -> @exp:U32 -> @sh:U32 -> @sl:U32 -> F64
def F64.hi source · line 73 · raw
@a:F64 -> U32
def F64.lo source · line 78 · raw
@a:F64 -> U32
def W2.nz source · line 83 · raw
@w:W2 -> Bool
def W2.bit.at source · line 88 · raw
@low:Bool -> @n:U32 -> @hi:U32 -> @lo:U32 -> U32
def W2.bit source · line 95 · raw
@w:W2 -> @+n:U32 -> U32
def W2.ge.eq source · line 100 · raw
@eq:Bool -> @al:U32 -> @bl:U32 -> Bool
def W2.ge.hi source · line 107 · raw
@gt:Bool -> @eq:Bool -> @al:U32 -> @bl:U32 -> Bool
def W2.ge source · line 114 · raw
@a:W2 -> @b:W2 -> Bool
def W2.sub.of source · line 119 · raw
@ah:U32 -> @bh:U32 -> @al:U32 -> @bl:U32 -> @lo:U32 -> W2
def W2.sub source · line 122 · raw
@a:W2 -> @b:W2 -> W2
def W2.shl1 source · line 127 · raw
@w:W2 -> @bit:U32 -> W2
def W2.shl.small source · line 132 · raw
@z:Bool -> @+k:U32 -> @hi:U32 -> @+lo:U32 -> W2
def W2.shl.big source · line 139 · raw
@big:Bool -> @+k:U32 -> @w:W2 -> W2
def W2.shl source · line 146 · raw
@w:W2 -> @+k:U32 -> W2
def W2.msb.hi source · line 149 · raw
@z:Bool -> @hi:U32 -> @lo:U32 -> U32
def W2.msb source · line 156 · raw
@w:W2 -> U32
def W2.inc.carry source · line 161 · raw
@z:Bool -> @hi:U32 -> @lo:U32 -> W2
def W2.inc.of source · line 168 · raw
@hi:U32 -> @+lo:U32 -> W2
def W2.inc source · line 171 · raw
@w:W2 -> W2
def W4.nz source · line 176 · raw
@w:W4 -> Bool
def W4.shl1 source · line 181 · raw
@w:W4 -> W4
def W4.set0 source · line 186 · raw
@w:W4 -> W4
def Limb.add.s source · line 191 · raw
@+x:U32 -> @c:U32 -> @+s1:U32 -> Limb
def Limb.add source · line 195 · raw
@+x:U32 -> @y:U32 -> @c:U32 -> Limb
def Limb.sub.s source · line 198 · raw
@x:U32 -> @y:U32 -> @+br:U32 -> @+s1:U32 -> Limb
def Limb.sub source · line 201 · raw
@+x:U32 -> @+y:U32 -> @br:U32 -> Limb
def W4.add.a source · line 204 · raw
@d:U32 -> @c:U32 -> @b:U32 -> @limb:Limb -> W4
def W4.add.b source · line 209 · raw
@xa:U32 -> @ya:U32 -> @d:U32 -> @c:U32 -> @limb:Limb -> W4
def W4.add.c source · line 214 · raw
@xa:U32 -> @xb:U32 -> @ya:U32 -> @yb:U32 -> @d:U32 -> @limb:Limb -> W4
def W4.add.d source · line 219 · raw
@xa:U32 -> @xb:U32 -> @xc:U32 -> @ya:U32 -> @yb:U32 -> @yc:U32 -> @limb:Limb -> W4
def W4.add source · line 224 · raw
@x:W4 -> @y:W4 -> W4
def W4.sub.a source · line 229 · raw
@d:U32 -> @c:U32 -> @b:U32 -> @limb:Limb -> W4
def W4.sub.b source · line 234 · raw
@xa:U32 -> @ya:U32 -> @d:U32 -> @c:U32 -> @limb:Limb -> W4
def W4.sub.c source · line 239 · raw
@xa:U32 -> @xb:U32 -> @ya:U32 -> @yb:U32 -> @d:U32 -> @limb:Limb -> W4
def W4.sub.d source · line 244 · raw
@xa:U32 -> @xb:U32 -> @xc:U32 -> @ya:U32 -> @yb:U32 -> @yc:U32 -> @limb:Limb -> W4
def W4.sub source · line 249 · raw
@x:W4 -> @y:W4 -> W4
def W4.one source · line 254 · raw
W4
def W4.drop1 source · line 257 · raw
@w:W4 -> Pair(W4, Bool)
def W4.drop2 source · line 262 · raw
@w:W4 -> Pair(W4, Bool)
def W4.drop3 source · line 267 · raw
@w:W4 -> Pair(W4, Bool)
def W4.shr.bits.out source · line 272 · 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 275 · raw
@+k:Nat -> @j:Nat -> @w:W4 -> @lost:Bool -> Pair(W4, Bool)
def W4.shr.bits.z source · line 280 · raw
@z:Bool -> @+k:U32 -> @w:W4 -> @lost:Bool -> Pair(W4, Bool)
def W4.shr.bits source · line 287 · raw
@+k:U32 -> @w:W4 -> @lost:Bool -> Pair(W4, Bool)
def W4.shr.pair source · line 290 · raw
@bits:U32 -> @r:Pair(W4, Bool) -> Pair(W4, Bool)
def W4.shr.limbs source · line 294 · raw
@k:Nat -> @bits:U32 -> @w:W4 -> Pair(W4, Bool)
def W4.shr.wide source · line 307 · raw
@wide:Bool -> @+n:U32 -> @w:W4 -> Pair(W4, Bool)
def W4.shr source · line 314 · raw
@w:W4 -> @+n:U32 -> Pair(W4, Bool)
def W4.slide1 source · line 317 · raw
@w:W4 -> W4
def W4.slide2 source · line 322 · raw
@w:W4 -> W4
def W4.slide3 source · line 327 · raw
@w:W4 -> W4
def W4.shl.bits.go source · line 332 · raw
@+k:Nat -> @+j:Nat -> @w:W4 -> W4
def W4.shl.bits.z source · line 337 · raw
@z:Bool -> @+k:U32 -> @w:W4 -> W4
def W4.shl.bits source · line 344 · raw
@+k:U32 -> @w:W4 -> W4
def W4.shl.limbs source · line 347 · raw
@k:Nat -> @bits:U32 -> @w:W4 -> W4
def W4.shl.wide source · line 360 · raw
@wide:Bool -> @+n:U32 -> @w:W4 -> W4
def W4.shl source · line 367 · raw
@w:W4 -> @+n:U32 -> W4
def W4.msb.d source · line 370 · raw
@z:Bool -> @d:U32 -> Maybe<&2, U32>
def W4.msb.c source · line 377 · raw
@z:Bool -> @c:U32 -> @+d:U32 -> Maybe<&2, U32>
def W4.msb.b source · line 384 · raw
@z:Bool -> @b:U32 -> @+c:U32 -> @d:U32 -> Maybe<&2, U32>
def W4.msb.a source · line 391 · raw
@z:Bool -> @a:U32 -> @+b:U32 -> @c:U32 -> @d:U32 -> Maybe<&2, U32>
def W4.msb source · line 398 · raw
@w:W4 -> Maybe<&2, U32>
def mul32.of source · line 403 · raw
@+p00:U32 -> @+p01:U32 -> @+p10:U32 -> @+p11:U32 -> W2
def mul32 source · line 407 · raw
@+x:U32 -> @+y:U32 -> W2
def mul.sum6 source · line 414 · raw
@d:U32 -> @c:U32 -> @h11:U32 -> @b12:U32 -> @limb:Limb -> W4
def mul.sum5 source · line 419 · raw
@d:U32 -> @c:U32 -> @h11:U32 -> @+b:U32 -> @b12:U32 -> @carry:U32 -> W4
def mul.sum4 source · line 422 · raw
@d:U32 -> @c:U32 -> @h11:U32 -> @b1:U32 -> @carry:U32 -> @limb:Limb -> W4
def mul.sum3 source · line 427 · raw
@d:U32 -> @c:U32 -> @h10:U32 -> @h11:U32 -> @carry:U32 -> @limb:Limb -> W4
def mul.sum2 source · line 432 · raw
@d:U32 -> @c1:U32 -> @h01:U32 -> @h10:U32 -> @h11:U32 -> @l11:U32 -> @limb:Limb -> W4
def mul.sum1 source · line 437 · raw
@d:U32 -> @h01:U32 -> @l10:U32 -> @h10:U32 -> @h11:U32 -> @l11:U32 -> @limb:Limb -> W4
def mul.acc source · line 442 · raw
@p00:W2 -> @p01:W2 -> @p10:W2 -> @p11:W2 -> W4
def mul.wide source · line 447 · raw
@+xh:U32 -> @+xl:U32 -> @+yh:U32 -> @+yl:U32 -> W4
def div.bit.small source · line 450 · raw
@small:Bool -> @idx:U32 -> @ma:W2 -> U32
def div.bit source · line 457 · raw
@+p:Nat -> @ma:W2 -> U32
def div.ge source · line 460 · raw
@ge:Bool -> @rem:W2 -> @q:W4 -> @mb:W2 -> Step
def div.rem source · line 467 · raw
@+rem:W2 -> @q:W4 -> @+mb:W2 -> Step
def div.advance source · line 470 · raw
@p:Nat -> @st:Step -> @mb:W2 -> @ma:W2 -> Step
def div.finish source · line 475 · raw
@st:Step -> Pair(W4, Bool)
def div.go source · line 480 · raw
@k:Nat -> @st:Step -> @+mb:W2 -> @+ma:W2 -> Pair(W4, Bool)
def div.q source · line 488 · raw
@ma:W2 -> @mb:W2 -> Pair(W4, Bool)
def round.sub source · line 491 · raw
@sub:Bool -> @sign:U32 -> @exp:U32 -> @sh:U32 -> @sl:U32 -> F64
def round.zero.lo source · line 498 · raw
@zl:Bool -> @sign:U32 -> @exp:U32 -> @+sh:U32 -> @sl:U32 -> F64
def round.zero source · line 505 · raw
@zh:Bool -> @zl:Bool -> @sign:U32 -> @exp:U32 -> @+sh:U32 -> @sl:U32 -> F64
def round.inf source · line 512 · raw
@big:Bool -> @sign:U32 -> @exp:U32 -> @+sh:U32 -> @+sl:U32 -> F64
def round.pack source · line 519 · raw
@sign:U32 -> @+exp:U32 -> @sh:U32 -> @sl:U32 -> F64
def round.ov source · line 522 · raw
@ov:Bool -> @sign:U32 -> @exp:U32 -> @sh:U32 -> @sl:U32 -> F64
def round.inc source · line 529 · raw
@sign:U32 -> @exp:U32 -> @w:W2 -> F64
def round.should source · line 534 · raw
@+c:U32 -> @d:U32 -> @sl:U32 -> @sticky:Bool -> Bool
def round.up source · line 537 · raw
@up:Bool -> @sign:U32 -> @exp:U32 -> @sh:U32 -> @sl:U32 -> F64
def round.sig source · line 544 · raw
@sign:U32 -> @exp:U32 -> @sh:U32 -> @+sl:U32 -> @c:U32 -> @d:U32 -> @sticky:Bool -> F64
def round.go source · line 547 · raw
@sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.right.pair source · line 553 · raw
@sign:U32 -> @exp:U32 -> @sticky:Bool -> @r:Pair(W4, Bool) -> F64
def norm.right.sh source · line 557 · raw
@+sh:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.right source · line 560 · raw
@top:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.left.room0 source · line 563 · raw
@z:Bool -> @room:U32 -> @sign:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.left.fit source · line 570 · raw
@fit:Bool -> @+need:U32 -> @+room:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.left.room source · line 577 · raw
@+need:U32 -> @+room:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.left.need source · line 580 · raw
@need:U32 -> @sign:U32 -> @+exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.left source · line 583 · raw
@top:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.lo source · line 586 · raw
@lo:Bool -> @top:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.hi source · line 593 · raw
@hi:Bool -> @+top:U32 -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.top source · line 599 · raw
@m:Maybe<&2, U32> -> @sign:U32 -> @exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def norm.z source · line 606 · raw
@nz:Bool -> @sign:U32 -> @exp:U32 -> @+w:W4 -> @sticky:Bool -> F64
def norm.go source · line 613 · raw
@st:Norm -> F64
def under.pair source · line 618 · raw
@sign:U32 -> @sticky:Bool -> @r:Pair(W4, Bool) -> F64
def under.shr source · line 622 · raw
@sign:U32 -> @w:W4 -> @sticky:Bool -> @sh:U32 -> F64
def under.low source · line 625 · raw
@low:Bool -> @exp:U32 -> @sign:U32 -> @w:W4 -> @sticky:Bool -> F64
def under source · line 632 · raw
@sign:U32 -> @+exp:U32 -> @w:W4 -> @sticky:Bool -> F64
def mag.eq source · line 635 · raw
@eq:Bool -> @al:U32 -> @bl:U32 -> Bool
def mag.hi source · line 642 · raw
@lt:Bool -> @eq:Bool -> @al:U32 -> @bl:U32 -> Bool
def mag.same source · line 649 · raw
@eq:Bool -> @ma:W2 -> @mb:W2 -> Bool
def mag.exp source · line 656 · raw
@lt:Bool -> @eq:Bool -> @ma:W2 -> @mb:W2 -> Bool
def mag.lt source · line 663 · raw
@+ea:U32 -> @ma:W2 -> @+eb:U32 -> @mb:W2 -> Bool
def add.cancel source · line 666 · raw
@nz:Bool -> @sign:U32 -> @exp:U32 -> @total:W4 -> @sticky:Bool -> F64
def add.borrow source · line 673 · raw
@sign:U32 -> @exp:U32 -> @+total:W4 -> F64
def add.sub.lost source · line 676 · raw
@lost:Bool -> @sign:U32 -> @exp:U32 -> @+total:W4 -> F64
def add.sign source · line 683 · raw
@same:Bool -> @sign:U32 -> @exp:U32 -> @+aa:W4 -> @+trunc:W4 -> @lost:Bool -> F64
def add.pair source · line 690 · raw
@same:Bool -> @sign:U32 -> @exp:U32 -> @aa:W4 -> @r:Pair(W4, Bool) -> F64
def add.de source · line 694 · raw
@same:Bool -> @sa:U32 -> @ea:U32 -> @ma:W2 -> @de:U32 -> @mb:W2 -> F64
def add.ord source · line 698 · raw
@swap:Bool -> @+sa:U32 -> @+ea:U32 -> @+ma:W2 -> @+sb:U32 -> @+eb:U32 -> @+mb:W2 -> F64
def add.fin source · line 706 · raw
@+sa:U32 -> @+ea:U32 -> @+ma:W2 -> @+sb:U32 -> @+eb:U32 -> @+mb:W2 -> F64
def add.fin.z source · line 709 · 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 720 · 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 729 · raw
@same:Bool -> @sa:U32 -> F64
def add.inf.a source · line 736 · raw
@kb:Cls -> @+sa:U32 -> @sb:U32 -> F64
def add.ka source · line 745 · 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 754 · raw
@a:F64 -> @b:F64 -> @pa:Parts -> @pb:Parts -> F64
def unpack.sub source · line 759 · raw
@sub:Bool -> @exp:U32 -> @+h:U32 -> @l:U32 -> Parts
def unpack.nan source · line 766 · raw
@z:Bool -> @h:U32 -> Parts
def unpack.special source · line 773 · raw
@naninf:Bool -> @sub:Bool -> @exp:U32 -> @+h:U32 -> @l:U32 -> Parts
def unpack source · line 780 · raw
@+h:U32 -> @l:U32 -> Parts
def F64.add source · line 783 · raw
@a:F64 -> @b:F64 -> F64
def F64.neg source · line 788 · raw
@a:F64 -> F64
def F64.sub source · line 793 · raw
@a:F64 -> @b:F64 -> F64
def mul.sig source · line 796 · raw
@sa:U32 -> @ea:U32 -> @ma:W2 -> @sb:U32 -> @eb:U32 -> @mb:W2 -> F64
def mul.z source · line 801 · 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 810 · raw
@k:Cls -> Bool
def Cls.fin source · line 819 · raw
@k:Cls -> Bool
def Cls.nan source · line 828 · raw
@k:Cls -> Bool
def mul.inf.z source · line 837 · raw
@z:Bool -> @sign:U32 -> F64
def mul.inf source · line 844 · 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 851 · 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 858 · raw
@pa:Parts -> @pb:Parts -> F64
def F64.mul source · line 863 · raw
@a:F64 -> @b:F64 -> F64
def div.norm source · line 868 · raw
@k:U32 -> @mb:W2 -> W2
def div.sig.q source · line 871 · raw
@sign:U32 -> @exp:U32 -> @r:Pair(W4, Bool) -> F64
def div.sig source · line 875 · raw
@sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> @+k:U32 -> F64
def div.k source · line 878 · raw
@sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @+mb:W2 -> F64
def div.by0 source · line 881 · raw
@na:Bool -> @sign:U32 -> F64
def div.num0 source · line 888 · raw
@na:Bool -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64
def div.fin.z source · line 895 · raw
@nb:Bool -> @na:Bool -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64
def div.fin.a source · line 902 · raw
@ia:Bool -> @nb:Bool -> @na:Bool -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64
def div.fin.b source · line 909 · 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 916 · raw
@+ca:Cls -> @+cb:Cls -> @sign:U32 -> @ea:U32 -> @+ma:W2 -> @eb:U32 -> @+mb:W2 -> F64
def div.both source · line 919 · raw
@both:Bool -> @ca:Cls -> @cb:Cls -> @sign:U32 -> @ea:U32 -> @ma:W2 -> @eb:U32 -> @mb:W2 -> F64
def div.nan source · line 926 · 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 933 · raw
@pa:Parts -> @pb:Parts -> F64
def F64.div source · line 938 · raw
@a:F64 -> @b:F64 -> F64
def sqrt.step source · line 947 · raw
@ge:Bool -> @rem:W2 -> @root:W2 -> @trial:W2 -> SqrtStep
Restoring square root consumes 54 bit pairs: 53 significand bits and one guard bit.
def sqrt.trial source · line 954 · raw
@+rem:W2 -> @+root:W2 -> @+trial:W2 -> SqrtStep
def sqrt.advance source · line 957 · raw
@w:W4 -> @rem:W2 -> @+root:W2 -> SqrtStep
def sqrt.finish source · line 962 · raw
@exp:U32 -> @rem:W2 -> @root:W2 -> F64
def sqrt.go source · line 967 · raw
@n:Nat -> @+w:W4 -> @st:SqrtStep -> @exp:U32 -> F64
def sqrt.sig source · line 974 · raw
@+exp:U32 -> @sig:W2 -> F64
def sqrt.norm source · line 979 · raw
@exp:U32 -> @sig:W2 -> @+k:U32 -> F64
def sqrt.sign source · line 982 · raw
@positive:Bool -> @exp:U32 -> @+sig:W2 -> F64
def sqrt.zero source · line 989 · raw
@nz:Bool -> @+sign:U32 -> @exp:U32 -> @sig:W2 -> F64
def sqrt.inf source · line 996 · raw
@positive:Bool -> F64
def sqrt.parts source · line 1003 · raw
@parts:Parts -> F64
def F64.sqrt source · line 1012 · raw
@x:F64 -> F64
def F64.nan.bits source · line 1017 · raw
@+h:U32 -> @l:U32 -> Bool
def F64.zero.bits source · line 1020 · raw
@h:U32 -> @l:U32 -> Bool
def F64.is_nan source · line 1023 · raw
@a:F64 -> Bool
def F64.is_inf source · line 1028 · raw
@a:F64 -> Bool
def F64.is_zero source · line 1033 · raw
@a:F64 -> Bool
def F64.is_subnormal source · line 1038 · raw
@a:F64 -> Bool
def F64.eq.bits source · line 1043 · raw
@ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool
def F64.eq.zb source · line 1046 · raw
@zb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool
def F64.eq.zero source · line 1053 · raw
@za:Bool -> @zb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool
def F64.eq.nb source · line 1060 · raw
@nb:Bool -> @+ah:U32 -> @+al:U32 -> @+bh:U32 -> @+bl:U32 -> Bool
def F64.eq.nan source · line 1067 · raw
@na:Bool -> @nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool
def F64.is_eq source · line 1074 · raw
@a:F64 -> @b:F64 -> Bool
def F64.lt.eq source · line 1079 · raw
@eq:Bool -> @al:U32 -> @bl:U32 -> Bool
def F64.lt.hi source · line 1086 · raw
@lt:Bool -> @eq:Bool -> @al:U32 -> @bl:U32 -> Bool
def F64.lt.mag source · line 1093 · raw
@+ah:U32 -> @al:U32 -> @+bh:U32 -> @bl:U32 -> Bool
def F64.lt.neg source · line 1096 · raw
@nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool
def F64.lt.pos source · line 1103 · raw
@nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool
def F64.lt.sign source · line 1110 · raw
@na:Bool -> @nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool
def F64.lt.zb source · line 1117 · raw
@zb:Bool -> @+ah:U32 -> @al:U32 -> @+bh:U32 -> @bl:U32 -> Bool
def F64.lt.zero source · line 1124 · raw
@za:Bool -> @zb:Bool -> @+ah:U32 -> @al:U32 -> @+bh:U32 -> @bl:U32 -> Bool
def F64.lt.nb source · line 1131 · raw
@nb:Bool -> @+ah:U32 -> @+al:U32 -> @+bh:U32 -> @+bl:U32 -> Bool
def F64.lt.nan source · line 1138 · raw
@na:Bool -> @nb:Bool -> @ah:U32 -> @al:U32 -> @bh:U32 -> @bl:U32 -> Bool
def F64.is_lt source · line 1145 · raw
@a:F64 -> @b:F64 -> Bool
def F64.is_ne source · line 1150 · raw
@a:F64 -> @b:F64 -> Bool
def F64.is_le source · line 1153 · raw
@+a:F64 -> @+b:F64 -> Bool
def F64.is_gt source · line 1156 · raw
@a:F64 -> @b:F64 -> Bool
def F64.is_ge source · line 1159 · raw
@+a:F64 -> @+b:F64 -> Bool
def F64.abs source · line 1162 · raw
@a:F64 -> F64
def F64.from.lo source · line 1167 · raw
@+z:U32 -> @+n:U32 -> @hi_sh:U32 -> @lo_sh:U32 -> F64
def F64.from.small source · line 1170 · raw
@small:Bool -> @+z:U32 -> @+n:U32 -> F64
def F64.from.clz source · line 1177 · raw
@+z:U32 -> @n:U32 -> F64
def F64.from.z source · line 1180 · raw
@z:Bool -> @+n:U32 -> F64
def F64.from_u32 source · line 1187 · raw
@+n:U32 -> F64
def F64.one source · line 1190 · raw
F64
def F64.zero source · line 1193 · raw
F64
def F64.inf source · line 1196 · raw
F64
def trunc.mask source · line 1199 · raw
@high:Bool -> @+exp:U32 -> @hi:U32 -> @lo:U32 -> F64
def trunc.integral source · line 1206 · raw
@integral:Bool -> @+exp:U32 -> @hi:U32 -> @lo:U32 -> F64
def trunc.small source · line 1213 · raw
@small:Bool -> @+exp:U32 -> @+hi:U32 -> @lo:U32 -> F64
def trunc.nan source · line 1220 · raw
@nan:Bool -> @+hi:U32 -> @lo:U32 -> F64
def F64.trunc source · line 1228 · raw
@x:F64 -> F64
def integral.adjust source · line 1233 · raw
@adjust:Bool -> @t:F64 -> @step:F64 -> F64
def floor.truncated source · line 1240 · raw
@+x:F64 -> @+t:F64 -> F64
def F64.floor source · line 1243 · raw
@+x:F64 -> F64
def ceil.truncated source · line 1246 · raw
@+x:F64 -> @+t:F64 -> F64
def F64.ceil source · line 1249 · raw
@+x:F64 -> F64
def to_u32.shift source · line 1252 · raw
@high:Bool -> @+exp:U32 -> @hi:U32 -> @lo:U32 -> U32
def to_u32.range source · line 1259 · raw
@valid:Bool -> @+exp:U32 -> @hi:U32 -> @lo:U32 -> Maybe<&2, U32>
def to_u32.small source · line 1266 · raw
@small:Bool -> @+exp:U32 -> @+hi:U32 -> @lo:U32 -> Maybe<&2, U32>
def F64.to_u32 source · line 1273 · raw
@x:F64 -> Maybe<&2, U32>
def Txt.if source · line 1280 · 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 1288 · 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 1295 · raw
@+x:U32 -> @r:List<&2, U32> -> List<&2, U32>
def Big.norm source · line 1302 · raw
@xs:List<&2, U32> -> List<&2, U32>
def Big.mul1 source · line 1310 · 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 1318 · raw
@a:List<&2, U32> -> @z:Bool -> @+c:U32 -> List<&2, U32>
def Big.add source · line 1329 · raw
@a:List<&2, U32> -> @b:List<&2, U32> -> @+c:U32 -> List<&2, U32>
def Big.dec source · line 1339 · raw
@a:List<&2, U32> -> @z:Bool -> @+w:U32 -> List<&2, U32>
def Big.sub source · line 1351 · 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 1361 · raw
@hi:Cmp -> @lo:Cmp -> Cmp
def Big.cmp source · line 1370 · raw
@a:List<&2, U32> -> @b:List<&2, U32> -> Cmp
def Big.zeros source · line 1381 · raw
@n:Nat -> @xs:List<&2, U32> -> List<&2, U32>
def Big.shl source · line 1388 · raw
@xs:List<&2, U32> -> @+k:U32 -> List<&2, U32>
def Big.top source · line 1395 · raw
@xs:List<&2, U32> -> U32
def Big.bits source · line 1399 · raw
@+xs:List<&2, U32> -> U32
The bit length of a nonzero Big.
def Big.times source · line 1402 · raw
@n:Nat -> @+m:U32 -> @a:List<&2, U32> -> List<&2, U32>
def Big.any source · line 1409 · raw
@xs:List<&2, U32> -> Bool
def Big.w4 source · line 1417 · raw
@xs:List<&2, U32> -> W4
The low 128 bits as a W4.
def Big.digit source · line 1425 · 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 1445 · raw
@+c:U32 -> Bool
def Dec.push source · line 1448 · raw
@infrac:Bool -> @+v:U32 -> @acc:Dec -> Dec
def Rd.digits source · line 1453 · raw
@s:String -> @+infrac:Bool -> @+acc:Dec -> Pair(String, Dec)
def Rd.expo source · line 1463 · raw
@s:String -> @+n:U32 -> @+any:Bool -> Ex
The exponent saturates at 999999, far past any finite double.
def Rd.lower source · line 1472 · raw
@s:String -> String
def Rd.empty source · line 1479 · raw
@s:String -> Bool
def Rd.pos.cut source · line 1487 · 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 1490 · raw
@sign:U32 -> @+n:List<&2, U32> -> @e:U32 -> F64
def Div.go source · line 1495 · 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 1505 · raw
@sign:U32 -> @x:U32 -> @r:Pair(W4, Bool) -> F64
def Rd.div source · line 1509 · raw
@sign:U32 -> @x:U32 -> @num:List<&2, U32> -> @den:List<&2, U32> -> F64
def Rd.neg.go source · line 1514 · 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 1519 · raw
@sign:U32 -> @+d:List<&2, U32> -> @+s:List<&2, U32> -> @m:U32 -> F64
def Rd.neg source · line 1522 · raw
@sign:U32 -> @d:List<&2, U32> -> @+m:U32 -> F64
def Fast.mul.lo source · line 1529 · raw
@+x:W2 -> @ah:U32 -> @al:U32 -> @exact:Bool -> @low:W4 -> Cached
def Fast.mul source · line 1535 · raw
@+x:W2 -> @p:0x5eb40ff91b54d04ca8d44189421891b9/powers.Power -> Cached
The full 192-bit product lies between w * 2^64 and (w + 2) * 2^64.
def Fast.eq4 source · line 1540 · raw
@x:W4 -> @y:W4 -> Bool
def Fast.low source · line 1545 · raw
@w:W4 -> W2
def Fast.read.same source · line 1550 · raw
@same:Bool -> @value:F64 -> Maybe<&2, F64>
def Fast.read.round source · line 1557 · raw
@+sign:U32 -> @+exp:U32 -> @c:Cached -> Maybe<&2, F64>
def Fast.read.power source · line 1563 · raw
@sign:U32 -> @d:List<&2, U32> -> @p:0x5eb40ff91b54d04ca8d44189421891b9/powers.Power -> Maybe<&2, F64>
def Fast.read source · line 1568 · raw
@ok:Bool -> @sign:U32 -> @d:List<&2, U32> -> @eb:U32 -> Maybe<&2, F64>
def Rd.value.slow source · line 1575 · raw
@+sign:U32 -> @+d:List<&2, U32> -> @nd:U32 -> @+eb:U32 -> F64
def Rd.value.pick source · line 1584 · raw
@v:Maybe<&2, F64> -> @sign:U32 -> @d:List<&2, U32> -> @nd:U32 -> @eb:U32 -> F64
def Rd.value source · line 1592 · 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 1595 · raw
@neg:Bool -> @+n:U32 -> @+frac:U32 -> U32
def Rd.done source · line 1602 · raw
@sign:U32 -> @a:Dec -> @neg:Bool -> @n:U32 -> Maybe<&2, F64>
def Rd.eend source · line 1608 · raw
@sign:U32 -> @a:Dec -> @neg:Bool -> @ex:Ex -> Maybe<&2, F64>
def Rd.esign source · line 1613 · raw
@+sign:U32 -> @+a:Dec -> @s:String -> Maybe<&2, F64>
def Rd.exp source · line 1622 · raw
@sign:U32 -> @r:String -> @a:Dec -> Maybe<&2, F64>
def Rd.frac source · line 1629 · raw
@sign:U32 -> @p:Pair(String, Dec) -> Maybe<&2, F64>
def Rd.dot source · line 1633 · raw
@+sign:U32 -> @p:Pair(String, Dec) -> Maybe<&2, F64>
def Rd.body source · line 1642 · raw
@+sign:U32 -> @+s:String -> Maybe<&2, F64>
def F64.read source · line 1650 · 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 1667 · 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 1674 · raw
@even:Bool -> @r:List<&2, U32> -> @mm:List<&2, U32> -> Bool
def Sh.near source · line 1682 · raw
@c:Cmp -> @+d:U32 -> U32
A tie rounds to the even digit.
def Sh.pick source · line 1691 · 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 1706 · 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 1711 · raw
@+even:Bool -> @st:St -> Dig
def Sh.gen source · line 1717 · raw
@f:Nat -> @+even:Bool -> @o:Dig -> List<&2, U32>
def Sh.up source · line 1729 · 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 1743 · raw
@f:Nat -> @+even:Bool -> @small:Bool -> @st:St -> @+k:U32 -> Pair(St, U32)
def Sh.fix.down source · line 1758 · raw
@+even:Bool -> @sk:Pair(St, U32) -> Pair(St, U32)
def Sh.fix source · line 1765 · 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 1770 · raw
@pos:Bool -> @+n:Nat -> @st:St -> St
def Sh.chars source · line 1777 · raw
@ds:List<&2, U32> -> String
def Sh.fill source · line 1784 · raw
@n:Nat -> String
def Sh.exp.if source · line 1791 · raw
@small:Bool -> @+e:U32 -> String
def Sh.exp source · line 1798 · raw
@neg:Bool -> @+e:U32 -> String
def Sh.frac source · line 1805 · raw
@ds:String -> String
def Sh.sci source · line 1812 · raw
@ds:String -> @+k:U32 -> String
def Sh.fixed.big source · line 1819 · raw
@ge:Bool -> @+ds:String -> @+kn:Nat -> String
def Sh.fixed source · line 1826 · raw
@pos:Bool -> @+ds:String -> @+k:U32 -> String
def Sh.show.if source · line 1834 · raw
@sci:Bool -> @+ds:String -> @+k:U32 -> String
def Sh.fin source · line 1842 · raw
@+even:Bool -> @sk:Pair(St, U32) -> String
Like Python's repr: plain from 1e-4 up to 1e16, scientific outside.
def Fast.floor.same source · line 1849 · raw
@ok:Bool -> @w:W4 -> @exact:Bool -> Maybe<&2, Floor>
def Fast.floor.ends source · line 1856 · raw
@lo:Pair(W4, Bool) -> @hi:Pair(W4, Bool) -> @exact:Bool -> Maybe<&2, Floor>
def Fast.floor source · line 1861 · raw
@+shift:U32 -> @c:Cached -> Maybe<&2, Floor>
def Fast.div10.low source · line 1866 · raw
@hi:U32 -> @mid:U32 -> @+n:U32 -> Pair(W2, U32)
def Fast.div10.mid source · line 1869 · raw
@hi:U32 -> @lo:U32 -> @+n:U32 -> Pair(W2, U32)
def Fast.div10 source · line 1872 · raw
@w:W2 -> Pair(W2, U32)
def Fast.inc source · line 1877 · raw
@yes:Bool -> @w:W2 -> W2
def Fast.dec source · line 1884 · raw
@yes:Bool -> @w:W2 -> W2
def Fast.odd source · line 1891 · raw
@w:W2 -> Bool
def Fast.digits source · line 1896 · raw
@fuel:Nat -> @qr:Pair(W2, U32) -> @+ds:List<&2, U32> -> List<&2, U32>
def Fast.format source · line 1905 · raw
@w:W2 -> @index:U32 -> String
def Fast.short source · line 1910 · raw
@fuel:Nat -> @lower:Pair(W2, U32) -> @upper:Pair(W2, U32) -> @center:Pair(W2, U32) -> @+c:W2 -> @+index:U32 -> @+round:Bool -> @+tail:Bool -> String
def Fast.show.center source · line 1928 · raw
@+even:Bool -> @index:U32 -> @l:W4 -> @lexact:Bool -> @h:W4 -> @hexact:Bool -> @+half:Bool -> @+exact:Bool -> @shifted:Pair(W4, Bool) -> String
def Fast.show.floors source · line 1937 · raw
@even:Bool -> @index:U32 -> @lower:Floor -> @upper:Floor -> @center:Floor -> String
def Fast.show.power source · line 1942 · raw
@+f:W2 -> @+be:U32 -> @+near:Bool -> @+even:Bool -> @+index:U32 -> @p:0x5eb40ff91b54d04ca8d44189421891b9/powers.Power -> Maybe<&2, String>
def Fast.show source · line 1954 · raw
@+ex:U32 -> @+mh:U32 -> @+lo:U32 -> Maybe<&2, String>
def Sh.finite.go source · line 1963 · 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 1971 · raw
@+ex:U32 -> @+mh:U32 -> @+lo:U32 -> String
def Sh.finite.pick source · line 1976 · raw
@fast:Maybe<&2, String> -> @ex:U32 -> @mh:U32 -> @lo:U32 -> String
def Sh.sign source · line 1983 · raw
@neg:Bool -> @s:String -> String
def Sh.go source · line 1990 · raw
@naninf:Bool -> @zero:Bool -> @+neg:Bool -> @+ex:U32 -> @+mh:U32 -> @+lo:U32 -> String
def F64.show source · line 2002 · 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".