Pill and formatting

This commit is contained in:
Raymond Pasco 2015-08-06 15:39:35 -04:00
parent 6e5ecb0f3d
commit 6cb52e685d

View File

@ -1278,7 +1278,7 @@
[%n ~] [%n ~]
== ==
:: ::
++ fl :: arbitrary precision floating point ++ fl :: arb. precision fp
=+ ^- [[p=@u v=@s w=@u] r=?(%n %u %d %z %a) d=?(%d %f %i)] =+ ^- [[p=@u v=@s w=@u] r=?(%n %u %d %z %a) d=?(%d %f %i)]
[[113 -16.494 32.765] %n %d] [[113 -16.494 32.765] %n %d]
:: p=precision: number of bits in arithmetic form; must be at least 2 :: p=precision: number of bits in arithmetic form; must be at least 2
@ -1306,14 +1306,14 @@
++ add :: add; exact if e ++ add :: add; exact if e
|= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
=+ q=(dif:si e.a e.b) =+ q=(dif:si e.a e.b)
|- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exponent |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp
?: e ?: e
[%f & e.b (^add (lsh 0 (abs:si q) a.a) a.b)] [%f & e.b (^add (lsh 0 (abs:si q) a.a) a.b)]
=+ [ma=(met 0 a.a) mb=(met 0 a.b)] =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
=+ ^= w %+ dif:si e.a %- sun:si :: expanded exponent of a =+ ^= w %+ dif:si e.a %- sun:si :: expanded exp of a
?: (gth prc ma) (^sub prc ma) 0 ?: (gth prc ma) (^sub prc ma) 0
=+ ^= x %+ sum:si e.b (sun:si mb) :: highest exponent that b reaches =+ ^= x %+ sum:si e.b (sun:si mb) :: highest exp for b
?: =((cmp:si w x) --1) :: don't actually need to add ?: =((cmp:si w x) --1) :: don't need to add
?- r ?- r
%z (lug %fl a &) %d (lug %fl a &) %z (lug %fl a &) %d (lug %fl a &)
%a (lug %lg a &) %u (lug %lg a &) %a (lug %lg a &) %u (lug %lg a &)
@ -1425,7 +1425,7 @@
|= [t=?(%fl %ce %sm %lg %ne %na %nt) a=[e=@s a=@u] s=?] ^- fn |= [t=?(%fl %ce %sm %lg %ne %na %nt) a=[e=@s a=@u] s=?] ^- fn
?< =(a.a 0) ?< =(a.a 0)
=- =-
?. =(den %f) - :: if %f, flush denormals ?. =(den %f) - :: flush denormals
?. ?=([%f *] -) - ?. ?=([%f *] -) -
?: =((met 0 ->+>) prc) - [%f & zer] ?: =((met 0 ->+>) prc) - [%f & zer]
:: ::
@ -1466,7 +1466,7 @@
%ce ?: &(=(b 0) s) a a(a +(a.a)) %ce ?: &(=(b 0) s) a a(a +(a.a))
%ne ?~ b a %ne ?~ b a
=+ y=(bex (dec q)) =+ y=(bex (dec q))
?: &(=(b y) s) :: halfway rounds to even ?: &(=(b y) s) :: round halfs to even
?~ (dis a.a 1) a a(a +(a.a)) ?~ (dis a.a 1) a a(a +(a.a))
?: (^lth b y) a a(a +(a.a)) ?: (^lth b y) a a(a +(a.a))
%na ?~ b a %na ?~ b a
@ -1485,8 +1485,8 @@
?: =(den %i) [%f & a] ?: =(den %i) [%f & a]
?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp ?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp
:: ::
++ drg :: dragon4; convert to decimal ++ drg :: dragon4;
~/ %drg ~/ %drg :: convert to decimal
|= [a=[e=@s a=@u]] ^- [@s @u] |= [a=[e=@s a=@u]] ^- [@s @u]
?< =(a.a 0) ?< =(a.a 0)
=. a ?: (^lth (met 0 a.a) prc) (xpd a) a =. a ?: (^lth (met 0 a.a) prc) (xpd a) a
@ -1548,15 +1548,15 @@
|= [a=fn] ^- fn |= [a=fn] ^- fn
?-(-.a %f a(s !s.a), %i a(s !s.a), %n a) ?-(-.a %f a(s !s.a), %i a(s !s.a), %n a)
:: ::
++ swr ?+(r r %d %u, %u %d) :: flipped rounding mode ++ swr ?+(r r %d %u, %u %d) :: flipped rounding
++ prc ?>((gth p 1) p) :: enforce precision at least 2 ++ prc ?>((gth p 1) p) :: force >= 2 precision
++ den d :: denorms/flush/inf exponent range ++ den d :: denorm/flush/inf exp
++ emn v :: minimum exponent ++ emn v :: minimum exponent
++ emx (sum:si emn (sun:si w)) :: maximum exponent ++ emx (sum:si emn (sun:si w)) :: maximum exponent
++ spd [e=emn a=1] :: smallest denormal ++ spd [e=emn a=1] :: smallest denormal
++ spn [e=emn a=(bex (dec prc))] :: smallest normal ++ spn [e=emn a=(bex (dec prc))] :: smallest normal
++ lfn [e=emx a=(fil 0 prc 1)] :: largest ++ lfn [e=emx a=(fil 0 prc 1)] :: largest
++ lfe (sum:si emx (sun:si prc)) :: 2^lfe is larger than all floats ++ lfe (sum:si emx (sun:si prc)) :: 2^lfe is > than all
++ zer [e=--0 a=0] ++ zer [e=--0 a=0]
-- --
|% |%
@ -1668,11 +1668,11 @@
|= [a=fn] ^- fn |= [a=fn] ^- fn
(div [%f & --0 1] a) (div [%f & --0 1] a)
:: ::
++ sun :: unsigned integer to float ++ sun :: uns integer to float
|= [a=@u] ^- fn |= [a=@u] ^- fn
(rou [%f & --0 a]) (rou [%f & --0 a])
:: ::
++ san :: signed integer to float ++ san :: sgn integer to float
|= [a=@s] ^- fn |= [a=@s] ^- fn
=+ b=(old:si a) =+ b=(old:si a)
(rou [%f -.b --0 +.b]) (rou [%f -.b --0 +.b])
@ -1748,7 +1748,7 @@
=.(r swr (fli (^toj +>.a))) =.(r swr (fli (^toj +>.a)))
-- --
:: ::
++ ff :: ieee 754 format floating point ++ ff :: ieee 754 format fp
|_ [[w=@u p=@u b=@s] r=?(%n %u %d %z %a)] |_ [[w=@u p=@u b=@s] r=?(%n %u %d %z %a)]
:: this core has no use outside of the functionality :: this core has no use outside of the functionality
:: provided to ++rd, ++rs, ++rq, and ++rh :: provided to ++rd, ++rs, ++rq, and ++rh
@ -1776,9 +1776,9 @@
=+ r=(^add f (bex p)) =+ r=(^add f (bex p))
[%f s q r] [%f s q r]
:: ::
++ bit |= [a=fn] (bif (rou:pa a)) :: fn to @r with rounding ++ bit |= [a=fn] (bif (rou:pa a)) :: fn to @r w/ rounding
:: ::
++ bif :: fn to @r without rounding ++ bif :: fn to @r no rounding
|= [a=fn] ^- @r |= [a=fn] ^- @r
?: ?=([%i *] a) ?: ?=([%i *] a)
=+ q=(lsh 0 p (fil 0 w 1)) =+ q=(lsh 0 p (fil 0 w 1))
@ -1836,7 +1836,7 @@
|= [a=@r b=@r] (fall (gte:pa (sea a) (sea b)) |) |= [a=@r b=@r] (fall (gte:pa (sea a) (sea b)) |)
++ gth :: greater-than ++ gth :: greater-than
|= [a=@r b=@r] (fall (gth:pa (sea a) (sea b)) |) |= [a=@r b=@r] (fall (gth:pa (sea a) (sea b)) |)
++ sun :: unsigned integer to @r ++ sun :: uns integer to @r
|= [a=@u] (bit [%f & --0 a]) |= [a=@u] (bit [%f & --0 a])
++ san :: signed integer to @r ++ san :: signed integer to @r
|= [a=@s] (bit [%f (syn:si a) --0 (abs:si a)]) |= [a=@s] (bit [%f (syn:si a) --0 (abs:si a)])
@ -1848,16 +1848,16 @@
|= [a=dn] (bif (grd:pa a)) |= [a=dn] (bif (grd:pa a))
-- --
:: ::
++ rlyd |= a=@rd ^- dn (drg:rd a) :: prepare @rd for printing ++ rlyd |= a=@rd ^- dn (drg:rd a) :: prep @rd for print
++ rlys |= a=@rs ^- dn (drg:rs a) :: prepare @rs for printing ++ rlys |= a=@rs ^- dn (drg:rs a) :: prep @rs for print
++ rlyh |= a=@rh ^- dn (drg:rh a) :: prepare @rh for printing ++ rlyh |= a=@rh ^- dn (drg:rh a) :: prep @rh for print
++ rlyq |= a=@rq ^- dn (drg:rq a) :: prepare @rq for printing ++ rlyq |= a=@rq ^- dn (drg:rq a) :: prep @rq for print
++ ryld |= a=dn ^- @rd (grd:rd a) :: finish parsing of @rd ++ ryld |= a=dn ^- @rd (grd:rd a) :: finish parsing @rd
++ ryls |= a=dn ^- @rs (grd:rs a) :: finish parsing of @rs ++ ryls |= a=dn ^- @rs (grd:rs a) :: finish parsing @rs
++ rylh |= a=dn ^- @rh (grd:rh a) :: finish parsing of @rh ++ rylh |= a=dn ^- @rh (grd:rh a) :: finish parsing @rh
++ rylq |= a=dn ^- @rq (grd:rq a) :: finish parsing of @rq ++ rylq |= a=dn ^- @rq (grd:rq a) :: finish parsing @rq
:: ::
++ rd :: double precision floating point ++ rd :: double precision fp
~% %rd +> ~ ~% %rd +> ~
|_ r=?(%n %u %d %z) |_ r=?(%n %u %d %z)
:: round to nearest, round up, round down, round to zero :: round to nearest, round up, round down, round to zero
@ -1906,8 +1906,8 @@
++ gth ~/ %gth :: greater-than ++ gth ~/ %gth :: greater-than
|= [a=@rd b=@rd] ~| %rd-fail (gth:ma a b) |= [a=@rd b=@rd] ~| %rd-fail (gth:ma a b)
:: ::
++ sun |= [a=@u] ^- @rd (sun:ma a) :: unsigned integer to @rd ++ sun |= [a=@u] ^- @rd (sun:ma a) :: uns integer to @rd
++ san |= [a=@s] ^- @rd (san:ma a) :: signed integer to @rd ++ san |= [a=@s] ^- @rd (san:ma a) :: sgn integer to @rd
++ sig |= [a=@rd] ^- ? (sig:ma a) :: get sign ++ sig |= [a=@rd] ^- ? (sig:ma a) :: get sign
++ exp |= [a=@rd] ^- @s (exp:ma a) :: get exponent ++ exp |= [a=@rd] ^- @s (exp:ma a) :: get exponent
++ toi |= [a=@rd] ^- (unit ,@s) (toi:ma a) :: round to integer ++ toi |= [a=@rd] ^- (unit ,@s) (toi:ma a) :: round to integer
@ -1915,7 +1915,7 @@
++ grd |= [a=dn] ^- @rd (grd:ma a) :: decimal float to @rd ++ grd |= [a=dn] ^- @rd (grd:ma a) :: decimal float to @rd
-- --
:: ::
++ rs :: single precision floating point ++ rs :: single precision fp
~% %rs +> ~ ~% %rs +> ~
|_ r=?(%n %u %d %z) |_ r=?(%n %u %d %z)
:: round to nearest, round up, round down, round to zero :: round to nearest, round up, round down, round to zero
@ -1964,8 +1964,8 @@
++ gth ~/ %gth :: greater-than ++ gth ~/ %gth :: greater-than
|= [a=@rs b=@rs] ~| %rs-fail (gth:ma a b) |= [a=@rs b=@rs] ~| %rs-fail (gth:ma a b)
:: ::
++ sun |= [a=@u] ^- @rs (sun:ma a) :: unsigned integer to @rs ++ sun |= [a=@u] ^- @rs (sun:ma a) :: uns integer to @rs
++ san |= [a=@s] ^- @rs (san:ma a) :: signed integer to @rs ++ san |= [a=@s] ^- @rs (san:ma a) :: sgn integer to @rs
++ sig |= [a=@rs] ^- ? (sig:ma a) :: get sign ++ sig |= [a=@rs] ^- ? (sig:ma a) :: get sign
++ exp |= [a=@rs] ^- @s (exp:ma a) :: get exponent ++ exp |= [a=@rs] ^- @s (exp:ma a) :: get exponent
++ toi |= [a=@rs] ^- (unit ,@s) (toi:ma a) :: round to integer ++ toi |= [a=@rs] ^- (unit ,@s) (toi:ma a) :: round to integer
@ -1973,7 +1973,7 @@
++ grd |= [a=dn] ^- @rs (grd:ma a) :: decimal float to @rs ++ grd |= [a=dn] ^- @rs (grd:ma a) :: decimal float to @rs
-- --
:: ::
++ rq :: quadruple precision floating point ++ rq :: quad precision fp
~% %rq +> ~ ~% %rq +> ~
|_ r=?(%n %u %d %z) |_ r=?(%n %u %d %z)
:: round to nearest, round up, round down, round to zero :: round to nearest, round up, round down, round to zero
@ -2022,8 +2022,8 @@
++ gth ~/ %gth :: greater-than ++ gth ~/ %gth :: greater-than
|= [a=@rq b=@rq] ~| %rq-fail (gth:ma a b) |= [a=@rq b=@rq] ~| %rq-fail (gth:ma a b)
:: ::
++ sun |= [a=@u] ^- @rq (sun:ma a) :: unsigned integer to @rq ++ sun |= [a=@u] ^- @rq (sun:ma a) :: uns integer to @rq
++ san |= [a=@s] ^- @rq (san:ma a) :: signed integer to @rq ++ san |= [a=@s] ^- @rq (san:ma a) :: sgn integer to @rq
++ sig |= [a=@rq] ^- ? (sig:ma a) :: get sign ++ sig |= [a=@rq] ^- ? (sig:ma a) :: get sign
++ exp |= [a=@rq] ^- @s (exp:ma a) :: get exponent ++ exp |= [a=@rq] ^- @s (exp:ma a) :: get exponent
++ toi |= [a=@rq] ^- (unit ,@s) (toi:ma a) :: round to integer ++ toi |= [a=@rq] ^- (unit ,@s) (toi:ma a) :: round to integer
@ -2031,7 +2031,7 @@
++ grd |= [a=dn] ^- @rq (grd:ma a) :: decimal float to @rq ++ grd |= [a=dn] ^- @rq (grd:ma a) :: decimal float to @rq
-- --
:: ::
++ rh :: half precision floating point ++ rh :: half precision fp
|_ r=?(%n %u %d %z) |_ r=?(%n %u %d %z)
:: round to nearest, round up, round down, round to zero :: round to nearest, round up, round down, round to zero
:: ::
@ -2061,8 +2061,8 @@
++ gth ~/ %gth :: greater-than ++ gth ~/ %gth :: greater-than
|= [a=@rh b=@rh] ~| %rh-fail (gth:ma a b) |= [a=@rh b=@rh] ~| %rh-fail (gth:ma a b)
:: ::
++ sun |= [a=@u] ^- @rh (sun:ma a) :: unsigned integer to @rh ++ sun |= [a=@u] ^- @rh (sun:ma a) :: uns integer to @rh
++ san |= [a=@s] ^- @rh (san:ma a) :: signed integer to @rh ++ san |= [a=@s] ^- @rh (san:ma a) :: sgn integer to @rh
++ sig |= [a=@rh] ^- ? (sig:ma a) :: get sign ++ sig |= [a=@rh] ^- ? (sig:ma a) :: get sign
++ exp |= [a=@rh] ^- @s (exp:ma a) :: get exponent ++ exp |= [a=@rh] ^- @s (exp:ma a) :: get exponent
++ toi |= [a=@rh] ^- (unit ,@s) (toi:ma a) :: round to integer ++ toi |= [a=@rh] ^- (unit ,@s) (toi:ma a) :: round to integer
@ -2248,7 +2248,7 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 2cJ, extra math :: :: section 2cJ, extra math ::
:: ::
++ sqt :: square root w/remainder ++ sqt :: sqrt w/remainder
~/ %sqt ~/ %sqt
|= a=@ ^- [p=@ q=@] |= a=@ ^- [p=@ q=@]
?~ a [0 0] ?~ a [0 0]
@ -5864,8 +5864,8 @@
?: (lth b 256) ?: (lth b 256)
[[b (end 0 b d)] ~] [[b (end 0 b d)] ~]
[[256 d] $(c d, b (sub b 256))] [[256 d] $(c d, b (sub b 256))]
++ raws :: random bits continuation ++ raws :: random bits
|= b=@ |= b=@ :: continuation
=+ r=(raw b) =+ r=(raw b)
[r +>.$(a (shas %og-s r))] [r +>.$(a (shas %og-s r))]
-- --