src/float/format.bend checks
raw source on the hub · import 0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/format.bend as Format
2 imports
import Base import ./bin.bend as Bin
Types
type Val source · line 20 · raw
Data
Z@neg:Bool -> Val
Inf@neg:Bool -> Val
NaNVal
Fin@neg:Bool -> @m:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @e:Nat -> Val
type Format source · line 28 · raw
Data
p: mantissa bits; emin, emax: lowest and highest exponent (offset by 300) of a mantissa's last bit
Format@p:Nat -> @emin:Nat -> @emax:Nat -> Format
Definitions
def binary32 source · line 32 · raw
Format
binary32: 24 bits; smallest subnormal 2^-149; largest 2^104 * (2^24 - 1)
def strip source · line 37 · raw
@neg:Bool -> @m:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @e:Nat -> Val
the same value with its low zero bits moved into the exponent and its high zero bits dropped, so that equal values are equal terms
def canon source · line 46 · raw
@v:Val -> Val
def over.go source · line 60 · raw
@neg:Bool -> @m:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @e:Nat -> @zero:Bool -> @big:Bool -> Val
def over source · line 69 · raw
@+top:Nat -> @neg:Bool -> @+m:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @+e:Nat -> Val
def round.up source · line 72 · raw
@q:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @up:Bool -> 0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin
def round.fin source · line 79 · raw
@+top:Nat -> @neg:Bool -> @+t:Nat -> @qrs:Pair(0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin, Pair(Bool, Bool)) -> Val
def round.go source · line 83 · raw
@+top:Nat -> @neg:Bool -> @m:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @+e:Nat -> @+t:Nat -> @exact:Bool -> Val
def round source · line 91 · raw
@f:Format -> @neg:Bool -> @+m:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @+e:Nat -> Val
the float of format f nearest to (-1)^neg * m * 2^(e - 300), ties to even
def add.fin.cmp source · line 100 · raw
@f:Format -> @na:Bool -> @nb:Bool -> @a:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @b:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @e:Nat -> @c:Cmp -> Val
add two finite values once their mantissas share the exponent e
def add.fin.signs source · line 109 · raw
@f:Format -> @na:Bool -> @nb:Bool -> @+a:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @+b:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @e:Nat -> @differ:Bool -> Val
def add.fin.aligned source · line 116 · raw
@f:Format -> @+na:Bool -> @+nb:Bool -> @a:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @b:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @e:Nat -> Val
def add.fin.go source · line 119 · raw
@f:Format -> @na:Bool -> @a:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @+ea:Nat -> @nb:Bool -> @b:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @+eb:Nat -> @a_high:Bool -> Val
def add.fin source · line 126 · raw
@f:Format -> @na:Bool -> @a:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @+ea:Nat -> @b:Val -> Val
def add.inf.go source · line 137 · raw
@na:Bool -> @differ:Bool -> Val
def add.inf source · line 144 · raw
@+na:Bool -> @b:Val -> Val
def add.zero source · line 155 · raw
@na:Bool -> @b:Val -> Val
def spec_add source · line 167 · raw
@f:Format -> @a:Val -> @b:Val -> Val
IEEE addition: the exact sum, rounded; x + (-x) is +0
def neg source · line 178 · raw
@v:Val -> Val
def spec_sub source · line 189 · raw
@f:Format -> @a:Val -> @b:Val -> Val
def mul.fin source · line 195 · raw
@f:Format -> @na:Bool -> @a:0x5f97f469d15c04a181dae0e4e64e1d3d/src/float/bin.Bin -> @ea:Nat -> @b:Val -> Val
def mul.inf source · line 206 · raw
@na:Bool -> @b:Val -> Val
def mul.zero source · line 217 · raw
@na:Bool -> @b:Val -> Val
def spec_mul source · line 229 · raw
@f:Format -> @a:Val -> @b:Val -> Val
IEEE multiplication: the exact product, rounded