@@ -1,6 +1,5832 @@
3+ title/'3b: Floating Point'
14+A mold for the floating-point arithmetic using the base of two, the formula is
17+Produces either a float (`$f`), an infinity of other sign (`$i`),
18+or not-a-number (`$n`). `s` refers to sign, the `flag`s `&` or `|`; `e` to
19+exponent, a signed decimal; and `a` to the significand, an unsigned integer.
25+ $% [$f s=? e=@s a=@u]
37+ > (add:fl [%f & --33 2] [%f | --23 2])
38+ [%f s=%.y e=-79 a=10.374.452.512.267.829.421.849.019.032.797.184]
40+ > (add:fl [%i &] [%i &])
43+ > (add:fl [%n ~] [%i |])
46+ > (sun:fl 961.193.554.848.514.048.973.893.027.381.506.219.443)
47+ [%f s=%.y e=--17 a=7.333.324.850.834.000.007.430.214.137.126.970]
56+A mold for the floating-point arithmetic using the base of 10; the formula is
59+Valid values are a float (`$d`), an infinity (`$i`), or a not-a-number (`$n`).
60+`s` refers to sign, the `flag`s `&` or `|`; `e` to exponent, a signed decimal;
61+and `a` to the significand, an unsigned integer.
65+ $% [$d s=? e=@s a=@u]
74+ > `dn`[%d & --0 17.163.091.968]
75+ [%d s=%.y e=--0 a=17.163.091.968]
89+A mold for the floating-point arithmetic using the base of 10; the formula is
92+Produces either a parsed float (`$d`), infinity of either sign (`$i`), or
98+ $% [$d a=? b=[c=@ [d=@ e=@] f=? i=@]]
107+ > `rn`[%d | [2 [3 4] | 17.163]]
108+ [%d a=%.n b=[c=2 [d=3 e=4] f=%.n i=17.163]]
114+Arbitrary-precision floating-point
116+Container arm for floating-point arithmetic functions.
118+- Precision (`p`): number of bits in the significand; must be at least 2.
120+- Minimum exponent (`v`): minimum value of e. Default is -16.494.
121+- Width (`w`): Max value of `e` minus min value of `e`. 0 is for fixed-point.
123+- Rounding mode (`r`): Possible modes are nearest (`$n`), up (`$u`),
124+ down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%n`.
125+- Behavior (`d`): return denormals (`$d`), flush denormals to zero (`$z`),
126+ infinite exponent range (`$i`). Default value is `%d`.
132+ =+ ^- [[p=@u v=@s w=@u] r=$?($n $u $d $z $a) d=$?($d $f $i)]
133+ [[113 -16.494 32.765] %n %d]
144+Rounds `a` to a the nearest float that can be represented with a 113-bit
145+significand. There is no term to sign the significand, meaning that a positive
146+sign will always be produced.
150+`a` is a cell of a signed integer and an unsigned integer.
160+ |= [a=[e=@s a=@u]] ^- fn (rau a &)
166+ > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
167+ > (^rou:fl [--12 a])
168+ [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
170+ > (^rou:fl [--12 (add a 1)])
171+ [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
173+ > (^rou:fl [--12 (add a 300)])
174+ [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
176+ > (^rou:fl [--12 (add a 1.000)])
177+ [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
185+Rounds `a` based on what the state of of `r` in the core contained in `fl`. `t`
186+is a sticky bit that represents a value less than ULP(a) = 2^(e.a) when passed
191+`a` is a cell of a signed integer and an unsigned integer.
203+ |= [a=[e=@s a=@u] t=?] ^- fn
205+ $z (lug %fl a t) $d (lug %fl a t)
206+ $a (lug %ce a t) $u (lug %ce a t)
214+ > (rau:fl [-18 342.602.577] &)
215+ [%f s=%.y e=-102 a=6.626.897.619.228.945.634.459.505.846.648.832]
221+See `lug:fl` for possible rounding operations.
228+Produces the sum of `a` and `b`. `e` is used to choose between an exact result
229+(any-sized significand) or a rounded result (113-bit significand).
231+There is no term to sign the significands, so a positive sign will always be
250+ |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
251+ =+ q=(dif:si e.a e.b)
252+ |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp
254+ [%f & e.b (^add (lsh 0 (abs:si q) a.a) a.b)]
255+ =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
256+ =+ ^= w %+ dif:si e.a %- sun:si :: expanded exp of a
257+ ?: (gth prc ma) (^sub prc ma) 0
258+ =+ ^= x %+ sum:si e.b (sun:si mb) :: highest exp for b
259+ ?: =((cmp:si w x) --1) :: don't need to add
261+ $z (lug %fl a &) $d (lug %fl a &)
262+ $a (lug %lg a &) $u (lug %lg a &)
265+ (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)])
271+ > (^add:fl [--33 2.718] [--23 11] %.y)
272+ [%f s=%.y e=--23 a=2.783.243]
274+ > (^add:fl [--33 2.718] [--23 11] %.n)
275+ [%f s=%.y e=-68 a=6.890.975.897.521.519.304.902.126.405.156.864]
283+Produces the difference of `a` minus `b.` `e` is used to choose between an exact
284+result (any-sized significand) or a rounded result (113-bit significand).
288+`a` is a cell of a signed integer and an unsigned integer.
290+`b` is a cell of a signed integer and an unsigned integer.
302+ |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
303+ =+ q=(dif:si e.a e.b)
305+ (fli $(b a, a b, q +(q), r swr))
306+ =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
307+ =+ ^= w %+ dif:si e.a %- sun:si
308+ ?: (gth prc ma) (^sub prc ma) 0
309+ =+ ^= x %+ sum:si e.b (sun:si +(mb))
310+ ?: &(!e =((cmp:si w x) --1))
312+ $z (lug %sm a &) $d (lug %sm a &)
313+ $a (lug %ce a &) $u (lug %ce a &)
316+ =+ j=(lsh 0 (abs:si q) a.a)
318+ (fli $(a.b j, j a.b, r swr))
321+ ?: e [%f & e.b i] (rou [e.b i])
327+ > (^sub:fl [--33 2.718] [--23 11] %.y)
328+ [%f s=%.y e=--23 a=2.783.221]
330+ > (^sub:fl [--33 2.718] [--63 11] %.y)
331+ [%f s=%.n e=--33 a=11.811.157.346]
339+Produces the product of `a` multiplied by `b`. There is no term to sign the
340+significands, so a positive sign will always be produced.
344+`a` is a cell of a signed integer and an unsigned integer.
346+`b` is a cell of a signed integer and an unsigned integer.
356+ |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
357+ (rou (sum:si e.a e.b) (^mul a.a a.b))
363+ > (^mul:fl [--3 2.718] [--23 11])
364+ [%f s=%.y e=-72 a=9.475.054.411.405.900.661.487.108.108.582.912]
372+Produces the quotient of `a` divided by `b`. There is no term to sign the
373+significands, so a positive sign will always be produced.
377+`a` is a cell of a signed integer and an unsigned integer.
379+`b` is a cell of a signed integer and an unsigned integer.
389+ |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
390+ =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
391+ =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc))))
392+ =. a ?: (syn:si v) a
393+ a(e (sum:si v e.a), a (lsh 0 (abs:si v) a.a))
394+ =+ [j=(dif:si e.a e.b) q=(dvr a.a a.b)]
395+ (rau [j p.q] =(q.q 0))
401+ > (^div:fl [--13 2.718] [--23 11])
402+ [%f s=%.y e=-115 a=10.023.198.055.040.952.765.870.659.817.343.907]
410+Produces the square root of `a`.
414+`a` is a cell of a signed integer and an unsigned integer.
424+ |= [a=[e=@s a=@u]] ^- fn
426+ =+ [w=(met 0 a.a) x=(^mul +(prc) 2)]
427+ =+ ?:((^lth w x) (^sub x w) 0)
428+ =+ ?: =((dis - 1) (dis (abs:si e.a) 1)) -
430+ a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
431+ =+ [y=(^sqt a.a) z=(fra:si e.a --2)]
432+ (rau [z p.y] =(q.y 0))
438+ > (^sqt:fl [-18 342.602.577])
439+ [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
447+Tests if `a` is less than `b`.
451+`a` is a cell of a signed integer and an unsigned integer.
453+`b` is a cell of a signed integer and an unsigned integer.
463+ |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
464+ ?: =(e.a e.b) (^lth a.a a.b)
465+ =+ c=(cmp:si (ibl a) (ibl b))
466+ ?: =(c -1) & ?: =(c --1) |
467+ ?: =((cmp:si e.a e.b) -1)
468+ (^lth (rsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
469+ (^lth (lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
475+ > (^lth:fl [-4 684] [--0 35])
478+ > (^lth:fl [-4 684] [--0 90])
487+Tests if `a` is equal to `b`.
491+`a` is a cell of a signed integer and an unsigned integer.
493+`b` is a cell of a signed integer and an unsigned integer.
503+ |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
504+ ?. =((ibl a) (ibl b)) |
505+ ?: =((cmp:si e.a e.b) -1)
506+ =((lsh 0 (abs:si (dif:si e.a e.b)) a.b) a.a)
507+ =((lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
513+ > (^equ:fl [-4 480] [-0 50])
516+ > (^equ:fl [-4 480] [-0 30])
523+Integer binary logarithm
525+Produces the lowest power to which the number 2 must be raised to obtain `a` or
530+`a` is a cell of a signed integer and an unsigned integer.
540+ |= [a=[e=@s a=@u]] ^- @s
541+ (sum:si (sun:si (dec (met 0 a.a))) e.a)
547+ > (ibl:fl [-18 342.602.577])
554+Change representation to odd
556+Produces another representation of the floating point `a` where the significand
557+is odd. Every floating-point number has a unique representation of this kind. If
558+the significand of `a` is already odd, nothing changes.
562+`a` is a cell of a signed integer and an unsigned integer.
566+A cell of a signed integer and an unsigned integer.
573+ |- ?: =((end 0 1 a.a) 1) a
574+ $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1))
580+ > (uni:fl [-8 342.602.578])
581+ [e=-7 a=171.301.289]
583+ > (uni:fl [-8 342.602.577])
584+ [e=-8 a=342.602.577]
592+Produces the fully precise form of `a`, or the denormalized form of `a`.
596+`a` is a cell of a signed integer and an unsigned integer.
600+A cell of a signed integer and an unsigned integer.
609+ =+ ?: =(den %i) (^sub prc ma)
611+ =+ w=(dif:si e.a emn)
612+ ?: (syn:si w) (abs:si w) 0
613+ (min q (^sub prc ma))
614+ a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
621+ [e=-106 a=7.788.445.287.802.241.442.795.744.493.830.144]
623+ > (xpd:fl [-8 342.602.577])
624+ [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
626+ > (xpd:fl [-92 6.626.897.619.228.945.634.459.505.846.648.832])
627+ [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
633+Central rounding mechanism
635+Performs various rounding operations on `a`. An operation is chosen based on the
636+value selected for `t`. `s` is a sticky bit that represents a value less than
639+Possible rounding operations:
644+- Nearest (`$ne`) -- Rounds ties away from 0 if the number is even, rounds
645+ toward 0 if the number is odd.
649+`t` is one of the following: `$fl`, `$ce`, `$sm`, `$lg`, `$ne`, `$na`, or `$nt`.
651+`a` is a cell of a signed integer and an unsigned integer.
663+ :: central rounding mechanism
664+ :: can perform: floor, ceiling, smaller, larger,
665+ :: nearest (round ties to: even, away from 0, toward 0)
666+ :: s is sticky bit: represents a value less than ulp(a) = 2^(e.a)
670+ |= [t=$?($fl $ce $sm $lg $ne $na $nt) a=[e=@s a=@u] s=?] ^- fn
673+ ?. =(den %f) - :: flush denormals
675+ ?: =((met 0 ->+>) prc) - [%f & zer]
678+ ?> |(s (gth m prc)) :: require precision
680+ ?: (gth m prc) (^sub m prc) 0 :: reduce precision
681+ %- abs:si ?: =(den %i) --0 :: enforce min. exp
682+ ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0
683+ =^ b a :- (end 0 q a.a)
684+ a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a))
693+ $ne ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
694+ [%f & ?:((^lth b (bex (dec q))) zer spd)]
695+ $nt ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
696+ [%f & ?:((^lth b (bex (dec q))) zer spd)]
697+ $na [%f & ?:((^lth b (bex (dec q))) zer spd)]
706+ $sm ?. &(=(b 0) s) a
707+ ?: &(=(e.a emn) !=(den %i)) a(a (dec a.a))
708+ =+ y=(dec (^mul a.a 2))
709+ ?. (lte (met 0 y) prc) a(a (dec a.a))
710+ [(dif:si e.a --1) y]
711+ $ce ?: &(=(b 0) s) a a(a +(a.a))
714+ ?: &(=(b y) s) :: round halfs to even
715+ ?~ (dis a.a 1) a a(a +(a.a))
716+ ?: (^lth b y) a a(a +(a.a))
719+ ?: (^lth b y) a a(a +(a.a))
722+ ?: =(b y) ?: s a a(a +(a.a))
723+ ?: (^lth b y) a a(a +(a.a))
726+ =. a ?. =((met 0 a.a) +(prc)) a
727+ a(a (rsh 0 1 a.a), e (sum:si e.a --1))
730+ ?: =(den %i) [%f & a]
731+ ?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp
738+Get printable decimal
740+Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
741+accurate results for rounded floats.
745+`a` is a cell of a signed integer and an unsigned integer.
749+A cell of a signed integer and an unsigned integer.
756+ |= [a=[e=@s a=@u]] ^- [@s @u]
759+ =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a)
760+ =+ s=(lsh 0 ?.((syn:si e.a) (abs:si e.a) 0) 1)
761+ =+ mn=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) 1)
764+ ?& =(a.a (bex (dec prc))) :: if next smallest
765+ |(!=(e.a emn) =(den %i)) :: float is half ULP,
766+ == :: tighten lower bound
773+ =+ [k=--0 q=(^div (^add s 9) 10)]
781+ |- ?: (gte (^add (^mul r 2) mp) (^mul s 2))
782+ $(s (^mul s 10), k (sum:si k --1))
784+ |- :: r/s+o = a*10^-k
785+ =+ v=(dvr (^mul r 10) s)
793+ =+ l=(^lth (^mul r 2) mn) :: in lower bound
794+ =+ ^= h :: in upper bound
795+ ?| (^lth (^mul s 2) mp)
796+ (gth (^mul r 2) (^sub (^mul s 2) mp))
799+ $(o (^add (^mul o 10) u))
800+ =+ q=&(h |(!l (gth (^mul r 2) s)))
801+ =. o (^add (^mul o 10) ?:(q +(u) u))
809+ [%f s=%.y e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488]
810+ > (^drg:fl [e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488])
813+ > (sun:fl 102.057.673.128.349)
814+ [%f s=%.y e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936]
815+ > (^drg:fl [e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936])
816+ [--0 102.057.673.128.349]
824+Rounds float `a` to the nearest decimal float with an exponent of 0.
828+`a` is a cell of a signed integer and an unsigned integer.
838+ |= [a=[e=@s a=@u]] ^- fn
839+ ?. =((cmp:si e.a --0) -1) [%f & a]
842+ ?: |(=(r %d) =(r %z)) [%f & --0 y]
844+ ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))]
846+ ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y]
847+ ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)]
853+ > (^toj:fl [-11 7.530.107.827.833.587])
854+ [%f s=%.y e=--0 a=3.676.810.462.809]
856+ > (^toj:fl [-11 7.530.107.827.833.589])
857+ [%f s=%.y e=--0 a=3.676.810.462.809]
865+Produces `a` if `a` is a is of floating-point representation. If `a` is another
866+case of `fn`, such as infinity or not-a-number, a crash is produced.
874+A cell of a signed integer and an unsigned integer.
880+ |= [a=fn] ^- [$f s=? e=@s a=@u]
882+ ~_ leaf+"need-float"
890+ > (ned:fl [%f s=%.y e=-11 a=7.530.107.827.833.587])
891+ [%f s=%.y e=-11 a=7.530.107.827.833.587]
907+Multiplies `a` by 2 to the `b` power without rounding. This results in shifting
908+the exponent term by `b`.
914+`b` is a signed integer.
925+ ?: |(?=([$n *] a) ?=([$i *] a)) a
932+ > (shf:fl [[%f & -2 7] --2])
933+ [%f s=%.y e=--0 a=7]
935+ > (shf:fl [[%f & -2 7] -2])
938+ > (shf:fl [%f & -11 7.530.107.827.833.587] --5)
939+ [%f s=%.y e=-6 a=7.530.107.827.833.587]
947+Produces `a` with its signed changed from positive to negative, or vice versa.
962+ ?-(-.a $f a(s !s.a), $i a(s !s.a), $n a)
968+ > (fli:fl [%f %.y -2 7])
971+ > (fli:fl [%f %.n --2 30.617])
972+ [%f s=%.y e=--2 a=30.617]
974+ > (fli:fl [%f | --2 30.617])
975+ [%f s=%.y e=--2 a=30.617]
983+Switches the rounding mode of `r:fl`.
988+ ++ swr ?+(r r $d %u, $u %d)
999+ > =new-fl fl :: new fl core with changed state
1000+ > =new-fl new-fl(r %u)
1008+Force precision of 2 or greater
1010+Produces `p`, the core's precision, if `p` is greater than or equal to 2.
1011+Otherwise, a crash is produced.
1016+ ++ prc ?>((gth p 1) p)
1026+ > =new-fl new-fl(p 1)
1030+ > =new-fl new-fl(p 2)
1040+Produces `d:fl`. Denormalizes if `d:fl` is `%d`. Flushes denormals to zero if
1043+- Denormalizes if `d:fl` is `%d`.
1044+- Flushes denormals to zero if `d:fl` is `%f`.
1045+- Infinite exponent range if `$d` is `$i`.
1047+The default value of `d` is `%d`.
1062+ > =new-fl new-fl(d %f)
1072+Produces `v:fl`, the minimum exponent. The default minimum exponent is -16.494.
1092+Returns the maximum exponent of `fl`. The default maximum exponent is --16.494.
1097+ ++ emx (sum:si emn (sun:si w))
1112+Produces the smallest possible denormalized float.
1132+Produces the smallest representable normal float.
1137+ ++ spn [e=emn a=(bex (dec prc))]
1144+ [e=-16.494 a=5.192.296.858.534.827.628.530.496.329.220.096]
1152+Produces the largest representable normal float.
1157+ ++ lfn [e=emx a=(fil 0 prc 1)]
1164+ [e=--16.271 a=10.384.593.717.069.655.257.060.992.658.440.191]
1172+Produces the sum of `emx:fl` plus `prc:fl`.
1177+ ++ lfe (sum:si emx (sun:si prc)) :: 2^lfe is > than all
1192+Produces zero represented as a float.
1214+Rounds `a`. The way in which `a` is rounded depends on the value of `r:fl`.
1230+ ?~ a.a [%f s.a zer]
1232+ =.(r swr (fli (^rou +>.a)))
1238+ > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
1239+ > (rou:fl [%f & --12 a])
1240+ [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1242+ > (rou:fl [%f & --12 (add a 1)])
1243+ [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1245+ > (rou:fl [%f & --12 (add a 300)])
1246+ [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1248+ > (rou:fl [%f & --12 (add a 1.000)])
1249+ [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
1257+Produces the sign of `a`.
1272+ ?-(-.a $f s.a, $i s.a, $n &)
1278+ > (syn:fl (sun:fl 106))
1281+ > (syn:fl [%f | --0 106])
1290+Produces the absolute value of `a`.
1305+ ?: ?=([$f *] a) [%f & e.a a.a]
1306+ ?: ?=([$i *] a) [%i &] [%n ~]
1312+ > (abs:fl [%f | --0 106])
1313+ [%f s=%.y e=--0 a=106]
1315+ > (abs:fl [%f & --0 106])
1316+ [%f s=%.y e=--0 a=106]
1324+Produces the sum of `a` plus `b`.
1340+ |= [a=fn b=fn] ^- fn
1341+ ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1342+ ?: |(?=([$i *] a) ?=([$i *] b))
1343+ ?: &(?=([$i *] a) ?=([$i *] b))
1345+ ?: ?=([$i *] a) a b
1346+ ?: |(=(a.a 0) =(a.b 0))
1347+ ?. &(=(a.a 0) =(a.b 0)) %- rou ?~(a.a b a)
1348+ [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer]
1354+ ?: s.a (^add +>.a +>.b |)
1355+ =.(r swr (fli (^add +>.a +>.b |)))
1356+ ?: s.a (^sub +>.a +>.b |)
1363+ > (add:fl [%f & --0 106] [%f | --3 55])
1364+ [%f s=%.n e=-104 a=6.774.324.807.619.657.921.598.381.929.529.344]
1372+Produces the exact sum of `a` plus `b`.
1388+ |= [a=fn b=fn] ^- fn
1389+ ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1390+ ?: |(?=([$i *] a) ?=([$i *] b))
1391+ ?: &(?=([$i *] a) ?=([$i *] b))
1393+ ?: ?=([$i *] a) a b
1394+ ?: |(=(a.a 0) =(a.b 0))
1395+ ?. &(=(a.a 0) =(a.b 0)) ?~(a.a b a)
1396+ [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer]
1402+ ?: s.a (^add +>.a +>.b &)
1403+ (fli (^add +>.a +>.b &))
1404+ ?: s.a (^sub +>.a +>.b &)
1412+ > (ead:fl [%f & --0 106] [%f | --3 55])
1413+ [%f s=%.n e=--0 a=334]
1421+Produces the difference of `a` minus `b`.
1437+ |= [a=fn b=fn] ^- fn (add a (fli b))
1443+ > (sub:fl [%f & --13 2.718] [%f & --23 11])
1444+ [%f s=%.n e=-86 a=5.416.671.014.775.224.232.595.412.796.571.648]
1452+Produces the product of `a` multiplied by `b`.
1468+ |= [a=fn b=fn] ^- fn
1469+ ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1473+ ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1475+ ?: =(a.a 0) [%n ~] [%i =(s.a s.b)]
1476+ ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer]
1477+ ?: =(s.a s.b) (^mul +>.a +>.b)
1478+ =.(r swr (fli (^mul +>.a +>.b)))
1486+Produces the exact product of `a` multiplied by `b`.
1502+ |= [a=fn b=fn] ^- fn
1503+ ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1507+ ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1509+ ?: =(a.a 0) [%n ~] [%i =(s.a s.b)]
1510+ ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer]
1511+ [%f =(s.a s.b) (sum:si e.a e.b) (^^mul a.a a.b)]
1519+Produces the quotient of `a` divided by `b`.
1535+ |= [a=fn b=fn] ^- fn
1536+ ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1538+ ?: ?=([$i *] b) [%n ~] [%i =(s.a s.b)]
1539+ ?: ?=([$i *] b) [%f =(s.a s.b) zer]
1540+ ?: =(a.a 0) ?: =(a.b 0) [%n ~] [%f =(s.a s.b) zer]
1541+ ?: =(a.b 0) [%i =(s.a s.b)]
1542+ ?: =(s.a s.b) (^div +>.a +>.b)
1543+ =.(r swr (fli (^div +>.a +>.b)))
1551+Produces the sum of `c` plus the product of `a` multiplied by `b`;
1570+ |= [a=fn b=fn c=fn] ^- fn
1577+ > (fma:fl [%f & --13 2.718] [%f & --23 11] [%f & --13 2.718])
1578+ [%f s=%.y e=-62 a=9.475.054.514.089.037.465.004.673.635.188.736]=
1586+Produces the square root of `a`.
1601+ ?: ?=([$n *] a) [%n ~]
1602+ ?: ?=([$i *] a) ?:(s.a a [%n ~])
1603+ ?~ a.a [%f s.a zer]
1604+ ?: s.a (^sqt +>.a) [%n ~]
1610+ > (sqt:fl [%f s=%.y e=-18 a=342.602.577])
1611+ [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
1619+Produces the inverse of `a` by dividing `1` by `a`.
1634+ (div [%f & --0 1] a)
1640+ > (inv:fl [%f s=%.y e=--0 a=10])
1641+ [%f s=%.y e=-116 a=8.307.674.973.655.724.205.648.794.126.752.154]
1642+ > (drg:fl [%f s=%.y e=-116 a=8.307.674.973.655.724.205.648.794.126.752.154])
1643+ [%d s=%.y e=-1 a=1]
1645+ > (inv:fl [%f s=%.y e=--1 a=10])
1646+ [%f s=%.y e=-117 a=8.307.674.973.655.724.205.648.794.126.752.154]
1647+ > (drg:fl [%f s=%.y e=-117 a=8.307.674.973.655.724.205.648.794.126.752.154])
1648+ [%d s=%.y e=-2 a=5]
1650+ > (inv:fl [%f s=%.y e=--2 a=10])
1651+ [%f s=%.y e=-118 a=8.307.674.973.655.724.205.648.794.126.752.154]
1652+ > (drg:fl [%f s=%.y e=-118 a=8.307.674.973.655.724.205.648.794.126.752.154])
1653+ [%d s=%.y e=-3 a=25]
1659+Signed integer to float
1661+Produces `a` in floating-point representation.
1665+`a` is an unsigned integer.
1683+ [%f s=%.y e=--0 a=0]
1685+ > (sun:fl 5.048.729)
1686+ [%f s=%.y e=-90 a=6.250.023.776.601.238.669.911.180.544.311.296]
1695+Signed integer to float
1697+Produces the floating-point representation of `a`, an unsigned integer.
1701+`a` is an unsigned integer.
1713+ (rou [%f -.b --0 +.b])
1720+ [%f s=%.y e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1723+ [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1731+Tests if `a` is less than `b`. Returns `~` in the event of `a` or `b` being a
1748+ |= [a=fn b=fn] ^- (unit ?)
1749+ ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1751+ ?: ?=([$i *] a) !s.a ?: ?=([$i *] b) s.b
1752+ ?: |(=(a.a 0) =(a.b 0))
1753+ ?: &(=(a.a 0) =(a.b 0)) |
1754+ ?: =(a.a 0) s.b !s.a
1756+ ?: s.a (^lth +>.a +>.b) (^lth +>.b +>.a)
1762+ > (lth:fl (sun:fl 116) (sun:fl 4.820))
1765+ > (lth:fl (sun:fl 218.116) (sun:fl 4.820))
1768+ > (lth:fl (sun:fl 218.116) [%n ~])
1777+Tests whether `a` is less than or equal to `b`. Returns `~` in the event of `a`
1778+or `b` being a NaN (`[%n ~]`).
1794+ |= [a=fn b=fn] ^- (unit ?)
1795+ %+ bind (lth b a) |= a=? !a
1801+ > (lte:fl (sun:fl 102) [%f %.y -5 973.655.724])
1804+ > (lte:fl (sun:fl 102) [%f %.y -24 973.655.724])
1807+ > (lte:fl [%f %.y --2 25] (sun:fl 100))
1810+ > (lte:fl [%f %.y --2 25] [%f %.y --3 2])
1813+ > (lte:fl [%f %.y --2 25] [%n ~])
1822+Tests if `a` is equal to `b`. Returns `~` in the event of `a` or `b` being a NaN
1833+An `unit` of `flag`.
1839+ |= [a=fn b=fn] ^- (unit ?)
1840+ ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1842+ ?: |(?=([$i *] a) ?=([$i *] b)) |
1843+ ?: |(=(a.a 0) =(a.b 0))
1844+ ?: &(=(a.a 0) =(a.b 0)) & |
1845+ ?: |(=(e.a e.b) !=(s.a s.b)) |
1852+ > (equ:fl [%f %.y --2 25] (sun:fl 100))
1855+ > (equ:fl [%f %.y --2 25] (sun:fl 101))
1862+Greater or equal than
1864+Tests whether `a` is greater than or equal to `b`. Returns `~` in the event of
1865+`a` or `b` being a NaN (`[%n ~]`).
1875+An `unit` of `flag`.
1881+ |= [a=fn b=fn] ^- (unit ?) (lte b a)
1887+ > (gte:fl [%f %.y --2 25] (sun:fl 100))
1890+ > (gth:fl [%f %.y --6 73.989] [%f %.y --5 919.599])
1893+ > (gth:fl [%f %.y --6 73.989] [%n ~])
1902+Tests whether `a` is greater than `b`. Returns `~` in the event of `a` or `b`
1903+being a NaN (`[%n ~]`).
1913+An `unit` of `flag`.
1919+ |= [a=fn b=fn] ^- (unit ?) (lth b a)
1925+ > (gth:fl [%f %.y --2 25] (sun:fl 100))
1928+ > (gth:fl [%f %.y --6 73.989] [%f %.y --5 119.599])
1937+Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
1938+accurate results for rounded floats.
1953+ ?: ?=([$n *] a) [%n ~]
1954+ ?: ?=([$i *] a) [%i s.a]
1955+ ?~ a.a [%d s.a --0 0]
1956+ [%d s.a (^drg +>.a)]
1962+ > (drg:fl [%f | --6 73.989])
1963+ [%d s=%.n e=--0 a=4.735.296]
1971+Converts decimal `a` to `fn`.
1986+ ?: ?=([$n *] a) [%n ~]
1987+ ?: ?=([$i *] a) [%i s.a]
1991+ (mul [%f s.a --0 a.a] [%f & e.a (pow 5 q)])
1992+ (div [%f s.a --0 a.a] [%f & (sun:si q) (pow 5 q)])
1998+ > (grd:fl [%d s=%.n e=--0 a=73.989])
1999+ [%f s=%.n e=-96 a=5.862.012.516.267.904.074.208.723.341.410.304]
2001+ > (grd:fl [%d s=%.n e=--0 a=100])
2002+ [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
2008+Round to signed integer
2010+Rounds `a` to the nearest signed integer.
2024+ |= [a=fn] ^- (unit @s)
2026+ ?. ?=([$f *] b) ~ :- ~
2027+ =+ c=(^^mul (bex (abs:si e.b)) a.b)
2034+ > (toi:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514.406.400])
2035+ [~ u=--26.843.545.600]
2043+Rounds `a` to the nearest decimal integer.
2059+ ?~ a.a [%f s.a zer]
2061+ =.(r swr (fli (^toj +>.a)))
2068+ > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514.406.400])
2069+ [%f s=%.y e=--0 a=26.843.545.600]
2071+ > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514])
2072+ [%f s=%.y e=--0 a=26.844]
2074+ > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460])
2075+ [%f s=%.y e=--0 a=0]
2077+ > (toj:fl [%f s=%.y e=-9 a=9.002])
2078+ [%f s=%.y e=--0 a=16]
2086+Container core for IEEE-754 formatting operations.
2088+- `w` is width: The number of bits in the exponent field.
2089+- `p` is precision: The number of bits in the significand field.
2090+- `w` is bias: Added to exponent when storing.
2091+- `r` is rounding mode: Possible modes are nearest (`$n`), up (`$u`),
2092+ down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%a`.
2098+ |_ [[w=@u p=@u b=@s] r=$?($n $u $d $z $a)]
2104+ > =ffcore ~(. ff [8 8 0] %n)
2106+ <24.ltg {{{@ud @ud @ud} r/$n} <54.tyv 119.wim 31.ohr 1.jmk $143>}>
2113+`+ff` has no use outside of the functionality provided to other cores: `++rd`,
2114+`++rs`, `++rq`, and `++rh`. It's not intended to be used directly; it's just
2115+meant to power those cores.
2122+Produces the sign bit of `++ff`.
2127+ ++ sb (bex (^add w p))
2142+Produces the minimum possible exponent of `ff`.
2147+ ++ me (dif:si (dif:si --1 b) (sun:si p))
2162+Instantiates the core `fl`, giving values to its samples based on the
2163+configuration of the `ff` core.
2169+ %*(. fl p +(p), v me, w (^sub (bex w) 3), d %d, r r)
2175+ > ~(pa ff [11 52 --1.023] %n)
2178+ { {{p/@ v/@s w/@} r/?($n $u $a $d $z) d/$d}
2179+ <54.tyv 119.wim 31.ohr 1.jmk $143>
2186+`++pa` exists exclusively for internal use of `++ff`, and `++ff` exists for
2187+internal use in other cores.
2194+Converts `a` from `@r` to `fn`.
2198+`a` is a `@r`, an IEEE float.
2209+ =+ [f=(cut 0 [0 p] a) e=(cut 0 [p w] a)]
2212+ ?: =(f 0) [%f s --0 0] [%f s me f]
2213+ ?: =(e (fil 0 w 1))
2214+ ?: =(f 0) [%i s] [%n ~]
2215+ =+ q=:(sum:si (sun:si e) me -1)
2216+ =+ r=(^add f (bex p))
2224+ [%f s=%.y e=--0 a=0]
2230+`fn` to `@r`, rounding
2232+Converts `a` from `fn` to `@r` and applies rounding.
2245+ ++ bit |= [a=fn] (bif (rou:pa a))
2251+ > (bit:ma:rd [%f | -6 202])
2258+`fn` to `@r`, no rounding
2260+Converts `a` from `fn` to `@r`. No rounding is applied.
2264+`a` is a `@r`, an IEEE float.
2276+ =+ q=(lsh 0 p (fil 0 w 1))
2277+ ?: s.a q (^add q sb)
2278+ ?: ?=([$n *] a) (lsh 0 (dec p) (fil 0 +(w) 1))
2279+ ?~ a.a ?: s.a `@r`0 sb
2284+ ?: s.a `@r`a.a (^add a.a sb)
2285+ =+ q=(sum:si (dif:si e.a me) --1)
2286+ =+ r=(^add (lsh 0 p (abs:si q)) (end 0 p a.a))
2287+ ?: s.a r (^add r sb)
2302+Produces the sign of `a`.
2306+`a` is a `@r`, an IEEE float.
2317+ =(0 (cut 0 [(^add p w) 1] a))
2332+Produces the exponent of `a`.
2336+`a` is a `@r`, an IEEE float.
2347+ (dif:si (sun:si (cut 0 [p w] a)) b)
2362+Produces the sum of `a` plus `b`.
2366+`a` is a `@r`, an IEEE float.
2368+`b` is a `@r`, an IEEE float.
2372+A `@r`, an IEEE float.
2379+ (bif (add:pa (sea a) (sea b)))
2385+ > (add:ma:rd `@r`5 `@r`11)
2394+Produces the sum of `a` plus `b`.
2398+`a` is a `@r`, an IEEE float.
2400+`b` is a `@r`, an IEEE float.
2404+A `@r`, an IEEE float.
2411+ (bif (sub:pa (sea a) (sea b)))
2417+ > (sub:ma:rd `@r`5 `@r`11)
2426+Produces the product of `a` multiplied by `b`.
2430+`a` is a `@r`, an IEEE float.
2432+`b` is a `@r`, an IEEE float.
2436+A `@r`, an IEEE float.
2443+ (bif (mul:pa (sea a) (sea b)))
2449+ > (mul:ma:rd `@r`11 `@r`2)
2458+Produces the quotient of `a` divided by `b`.
2462+`a` is a `@r`, an IEEE float.
2464+`b` is a `@r`, an IEEE float.
2468+A `@r`, an IEEE float.
2475+ (bif (div:pa (sea a) (sea b)))
2481+ > (div:ma:rd `@r`175 `@r`26)
2490+Produces the sum of `c` plus the product of `a` multiplied by `b`;
2495+`a` is a `@r`, an IEEE float.
2497+`b` is a `@r`, an IEEE float.
2499+`c` is a `@r`, an IEEE float.
2503+A `@r`, an IEEE float.
2509+ |= [a=@r b=@r c=@r]
2510+ (bif (fma:pa (sea a) (sea b) (sea c)))
2516+ > (fma:ma:rd `@r`175 `@r`26 `@r`100)
2525+Produces the square root of `a`.
2529+`a` is a `@r`, an IEEE float.
2533+A `@r`, an IEEE float.
2540+ (bif (sqt:pa (sea a)))
2546+ > (sqt:ma:rd `@r`175)
2555+Tests whether `a` is less than `b`.
2559+`a` is a `@r`, an IEEE float.
2561+`b` is a `@r`, an IEEE float.
2571+ |= [a=@r b=@r] (fall (lth:pa (sea a) (sea b)) |)
2577+ > (lth:ma:rd `@rd`1 `@rd`2)
2580+ > (lth:ma:rd `@rd`10 `@rd`2)
2587+Less than or equal to
2589+Tests whether `a` is less than or equal to `b`.
2593+`a` is a `@r`, an IEEE float.
2595+`b` is a `@r`, an IEEE float.
2605+ |= [a=@r b=@r] (fall (lte:pa (sea a) (sea b)) |)
2611+ > (lte:ma:rd `@rd`10 `@rd`2)
2614+ > (lte:ma:rd `@rd`10 `@rd`10)
2623+Tests whether `a` is equal to `b`.
2627+`a` is a `@r`, an IEEE float.
2629+`b` is a `@r`, an IEEE float.
2639+ |= [a=@r b=@r] (fall (equ:pa (sea a) (sea b)) |)
2645+ > (equ:ma:rd `@rd`10 `@rd`2)
2648+ > (equ:ma:rd `@rd`10 `@rd`10)
2655+Greater or equal than
2657+Tests whether `a` is greater than or equal to `b`.
2661+`a` is a `@r`, an IEEE float.
2663+`b` is a `@r`, an IEEE float.
2673+ |= [a=@r b=@r] (fall (gte:pa (sea a) (sea b)) |)
2679+ > (gte:ma:rd `@rd`10 `@rd`10)
2682+ > (gte:ma:rd `@rd`10 `@rd`11)
2691+Tests whether `a` is greater than or equal to `b`.
2695+`a` is a `@r`, an IEEE float.
2697+`b` is a `@r`, an IEEE float.
2707+ |= [a=@r b=@r] (fall (gth:pa (sea a) (sea b)) |)
2713+ > (gth:ma:rd `@rd`10 `@rd`10)
2716+ > (gth:ma:rd `@rd`10 `@rd`9)
2723+Unsigned integer to `@r`
2725+Converts `a` from an unsigned integer (`@u`) to `@r`.
2729+`a` is `@u`, unsigned integer.
2733+A `@r`, an IEEE float.
2739+ |= [a=@u] (bit [%f & --0 a])
2745+ > (sun:ma:rd 658.149.282)
2752+Signed integer to `@r`
2754+Converts `a` from a signed integer to `@r`.
2758+`a` is `@s`, an unsigned integer
2762+A `@r`, an IEEE float.
2768+ |= [a=@s] (bit [%f (syn:si a) --0 (abs:si a)])
2783+Rounds `a` to the nearest signed integer.
2787+`a` is a `@r`, an IEEE float.
2797+ |= [a=@r] (toi:pa (sea a))
2803+ > (toi:ma:rd `@r`0x4af)
2810+`@r` to decimal float
2812+Converts `a` from `@r` to `dn` using the Dragon4 algorithm.
2816+`a` is a `@r`, an IEEE float.
2826+ |= [a=@r] (drg:pa (sea a))
2832+ > (drg:ma:rd `@r`0x41c0)
2833+ [%d s=%.y e=-323 a=8.316]
2835+ > (drg:ma:rd (sun:ma:rd 658.149.282))
2836+ [%d s=%.y e=--0 a=658.149.282]
2842+Decimal float to `@r`
2844+Converts `a` from `dn` to `@r`.
2852+A `@r`, an IEEE float.
2858+ |= [a=dn] (bif (grd:pa a))
2865+ > (grd:ma:rd [%d s=%.y e=--0 a=658.149.282])
2872+Prep `@rd` for print
2874+Converts `a` from a double-precision binary float to decimal64.
2878+`a` is a `@rd`, a double-precision float.
2887+ ++ rlyd |= a=@rd ^- dn (drg:rd a)
2893+ > (rlyd .~2.4703e-320)
2894+ [%d s=%.y e=-324 a=24.703]
2902+Converts `a` from a single-precision binary float to decimal32.
2906+`a` is a `@rs`, a single-precision float.
2915+ ++ rlys |= a=@rs ^- dn (drg:rs a)
2921+ > (rlys .1.681557e-39)
2922+ [%d s=%.y e=-45 a=1.681.557]
2928+Prep `@rh` for print
2930+Converts `a` from a half-precision binary float to decimal16.
2934+`a` is a `@rh`, a half-precision float.
2943+ ++ rlyh |= a=@rh ^- dn (drg:rh a)
2950+ [%d s=%.y e=--1 a=3]
2956+Prep `@rq` for print
2958+Converts `a` from a quad-precision binary float to decimal128.
2962+`a` is a `@rq`, a quad-precision float.
2971+ ++ rlyq |= a=@rq ^- dn (drg:rq a)
2977+ > (rlyq .~~~2.2628017865927756787440310766086816e-4343)
2978+ [%d s=%.y e=-4.377 a=22.628.017.865.927.756.787.440.310.766.086.816]
2984+Finish parsing `@rd`
2986+Converts `a` from a decimal float to a double-precision binary float.
2994+A a `@rd`, a double-precision float.
2999+ ++ ryld |= a=dn ^- @rd (grd:rd a)
3005+ > (ryld [%d s=%.y e=-324 a=24.703])
3012+Finish parsing `@rs`
3014+Converts `a` from a decimal float to a single-precision binary float.
3022+A a `@rs`, a single-precision float.
3027+ ++ ryls |= a=dn ^- @rs (grd:rs a)
3033+ > (ryls [%d s=%.y e=-324 a=24.703])
3036+ > (ryls [%d s=%.y e=-32 a=24.703])
3043+Finish parsing `@rh`
3045+Converts `a` from a decimal float to a half-precision binary float.
3053+A a `@rh`, a half-precision float.
3058+ ++ rylh |= a=dn ^- @rh (grd:rh a)
3064+ > (rylh [%d s=%.y e=--1 a=703])
3067+ > (rylh [%d s=%.y e=--3 a=56])
3070+ > (rylh [%d s=%.y e=--4 a=56])
3077+Finish parsing `@rq`
3079+Converts `a` from a decimal float to a quad-precision binary float.
3087+A a `@rq`, a quad-precision float.
3092+ ++ rylq |= a=dn ^- @rq (grd:rq a)
3098+ > (rylq [%d s=%.y e=-324 a=24.703])
3107+A container core for operations related to double-precision binary floats.
3109+`++rd` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3110+down (`$d`), and round to zero (`$z`).
3118+ |_ r=$?($n $u $d $z)
3126+Instantiates the core `ff`, giving values to its samples based on the
3127+configuration of the `rd` core.
3133+ %*(. ff w 11, p 52, b --1.023, r r)
3141+ {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3150+Converts `a` from a double-precision binary float to `fn`.
3153+ ++ sea :: @rd to fn
3154+ |= [a=@rd] (sea:ma a)
3160+ > (sea:rd .~4.94066e-319)
3161+ [%f s=%.y e=-1.074 a=100.000]
3169+Converts `a` from `fn` to a double-precision binary float.
3177+A `@rd`, a double-precision float.
3183+ |= [a=fn] ^- @rd (bit:ma a)
3189+ > (bit:rd [%f s=%.y e=-1.074 a=100.000])
3198+Produces the sum of `a` plus `b`.
3202+`a` is a `@rd`, a double-precision float.
3204+`b` is a `@rd`, a double-precision float.
3214+ |= [a=@rd b=@rd] ^- @rd
3222+ > (add:rd .~3.94066e12 .~9.2846e11)
3231+Produces the difference of `a` minus `b`.
3235+`a` is a `@rd`, a double-precision float.
3237+`b` is a `@rd`, a double-precision float.
3247+ |= [a=@rd b=@rd] ^- @rd
3255+ > (sub:rd .~7.94069e2 .~1.2846e3)
3256+ .~-4.9053099999999995e2
3264+Produces the product of `a` times `b`.
3268+`a` is a `@rd`, a double-precision float.
3270+`b` is a `@rd`, a double-precision float.
3280+ |= [a=@rd b=@rd] ^- @rd
3288+ > (mul:rd .~7.94069e2 .~1.2246e3)
3289+ .~9.724168973999998e5
3297+Produces the quotient of `a` divided by `b`.
3301+`a` is a `@rd`, a double-precision float.
3313+ |= [a=@rd b=@rd] ^- @rd
3321+ > (div:rd .~7.94099e2 .~1.2246e3)
3322+ .~6.484558223093255e-1
3330+Produces the sum of `c` plus the product of `a` multiplied by `b`;
3335+`a` is a `@rd`, an IEEE float.
3352+ |= [a=@rd b=@rd c=@rd] ^- @rd
3360+ > (fma:rd .~7.94099e2 .~1.2246e3 .~3.94066e3)
3369+Produces the square root of `a`.
3373+`a` is a `@rd`, a double-precision float.
3383+ |= [a=@rd] ^- @rd ~_ leaf+"rd-fail"
3390+ > (sqt:rd .~3.94066e3)
3391+ .~6.2774676422901614e1
3399+Test whether `a` is less than `b`.
3403+`a` is a `@rd`, a double-precision float.
3405+`b` is a `@rd`, a double-precision float.
3423+ > (lth:rd .~7.94099e2 .~1.2246e3)
3426+ > (lth:rd .~7.94099e2 .~1.2246e2)
3429+ > (lth:rd .~1.2246e2 .~1.2246e2)
3438+Test whether `a` is less than or equal to `b`.
3442+`a` is a `@rd`, a double-precision float.
3444+`b` is a `@rd`, a double-precision float.
3453+ ++ lte ~/ %lte :: less-equals
3462+ > (lte:rd .~7.94099e2 .~1.2246e3)
3465+ > (lte:rd .~7.94099e2 .~1.2246e2)
3468+ > (lte:rd .~1.2246e2 .~1.2246e2)
3477+Test whether `a` is equal to `b`.
3481+`a` is a `@rd`, a double-precision float.
3483+`b` is a `@rd`, a double-precision float.
3501+ > (equ:rd .~7.94099e2 .~1.2246e3)
3504+ > (equ:rd .~7.94099e2 .~1.2246e2)
3507+ > (equ:rd .~1.2246e2 .~1.2246e2)
3514+Greater than or equal
3516+Test whether `a` is greater than or equal to `b`.
3520+`a` is a `@rd`, a double-precision float.
3522+`b` is a `@rd`, a double-precision float.
3540+ > (gte:rd .~7.94099e2 .~1.2246e3)
3543+ > (gte:rd .~7.94099e2 .~1.2246e2)
3546+ > (gte:rd .~1.2246e2 .~1.2246e2)
3555+Test whether `a` is greater `b`.
3559+`a` is a `@rd`, a double-precision float.
3561+`b` is a `@rd`, a double-precision float.
3579+ > (gte:rd .~7.94099e2 .~1.2246e3)
3582+ > (gte:rd .~7.94099e2 .~1.2246e2)
3585+ > (gte:rd .~1.2246e2 .~1.2246e2)
3592+Unsigned integer to `@rd`
3594+Converts an unsigned integer `a` to `@rd`.
3598+`a` is a `@u`, an unsigned integer.
3607+ ++ sun |= [a=@u] ^- @rd (sun:ma a)
3620+Unsigned integer to `@rd`
3622+Converts a signed integer `a` to `@rd`.
3626+`a` is a `@s`, a signed integer.
3635+ ++ san |= [a=@s] ^- @rd (san:ma a)
3650+Produces the sign of `a`.
3663+ ++ sig |= [a=@rd] ^- ? (sig:ma a)
3669+ > (sig:rd .~1.2246e3)
3678+Produces the exponent of `a`.
3691+ ++ exp |= [a=@rd] ^- @s (exp:ma a) :: get exponent
3697+ > (exp:rd .~1.2246e3)
3706+Rounds `a` to the nearest integer.
3719+ ++ toi |= [a=@rd] ^- (unit @s) (toi:ma a)
3725+ > (toi:rd .~1.2246e3)
3732+`@rd` to decimal float
3734+Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
3735+accurate results for rounded floats.
3748+ ++ drg |= [a=@rd] ^- dn (drg:ma a)
3754+ > (drg:rd .~1.2246e3)
3755+ [%d s=%.y e=-1 a=12.246]
3761+Decimal float to `@rd`
3763+Converts `a` from decimal float to `@rd`.
3776+ ++ grd |= [a=dn] ^- @rd (grd:ma a) :: decimal float to @rd
3783+ > (grd:rd [%d s=%.y e=-1 a=12.246])
3792+A container core for operations related to single-precision binary floats.
3794+`++rs` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3795+down (`$d`), and round to zero (`$z`).
3803+ |_ r=$?($n $u $d $z)
3811+Instantiates the core `ff`, giving values to its samples based on the
3812+configuration of the `rs` core.
3818+ %*(. ff w 8, p 23, b --127, r r)
3826+ {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3835+Converts `a` from `@rs` to `fn`.
3839+`a` is a `@rs`, an single-precision float.
3849+ |= [a=@rs] (sea:ma a)
3855+ > (sea:rs .1.4e-43)
3856+ [%f s=%.y e=-149 a=100]
3864+Converts `a` from `fn` to `@rs`.
3872+A `@rs`, a single-precision float.
3878+ |= [a=fn] ^- @rs (bit:ma a)
3884+ > (bit:rs [%f & -2 1.000])
3893+Produces the sum of `a` plus `b`.
3897+`a` is a `@rs`, a single-precision float.
3909+ |= [a=@rs b=@rs] ^- @rs
3917+ > (add:rs .2.5e1 .2.5e2)
3926+Subtracts `a` from `b`.
3932+ |= [a=@rs b=@rs] ^- @rs
3940+ > (sub:rs .2.5e1 .2.5e2)
3949+Produces the product of `a` multiplied by `b`.
3953+`a` is a `@rs`, a single-precision float.
3965+ |= [a=@rs b=@rs] ^- @rs
3973+ > (mul:rs .2.5e1 .2.5e2)
3982+Produces the quotient of `a` divided by `b`.
3986+`a` is a `@rs`, a single-precision float.
3998+ |= [a=@rs b=@rs] ^- @rs
4006+ > (div:rs .4.5e1 .2.2e2)
4015+Produces the sum of `c` plus the product of `a` multiplied by `b`;
4020+`a` is a `@rs`, a single-precision float.
4034+ |= [a=@rs b=@rs c=@rs] ^- @rs
4042+ > (fma:rs .2.5e1 .2.5e2 .8.2e1)
4051+Produces the square root of `a`.
4055+`a` is a `@rs`, a single-precision float.
4082+Test whether `a` is less than `b`.
4086+`a` is a `@rs`, a single-precision float.
4106+ > (lth:rs .9.9e1 .1.1e2)
4109+ > (lth:rs .9.9e1 .9.9e1)
4118+Test whether `a` is less than or equal to `b`.
4122+`a` is a `@rs`, a single-precision float.
4142+ > (lte:rs .9.9e1 .1.1e2)
4145+ > (lte:rs .9.9e1 .9.9e1)
4154+Test whether `a` is equal to `b`.
4158+`a` is a `@rs`, a single-precision float.
4178+ > (equ:rs .9.9e1 .1.1e2)
4181+ > (equ:rs .9.9e1 .9.9e1)
4188+Greater than or equal
4190+Test whether `a` is greater than or equal to `b`.
4194+`a` is a `@rs`, a single-precision float.
4214+ > (gte:rs .9.9e1 .9.9e1)
4217+ > (gte:rs .9.9e1 .9.2e2)
4226+Test whether `a` is greater than `b`.
4230+`a` is a `@rs`, a single-precision float.
4250+ > (gth:rs .9.9e1 .9.2e2)
4253+ > (gth:rs .9.9e1 .9.9e1)
4256+ > (gth:rs .9.9e1 .1.9e1)
4263+Unsigned integer to `@rs`
4265+Converts `a` from an unsigned integer to `@rs`.
4269+`a` is an unsigned integer.
4278+ ++ sun |= [a=@u] ^- @rs (sun:ma a)
4291+Signed integer to `@rs`'
4293+Converts `a` from an unsigned integer to `@rs`.
4297+`a` is a signed integer.
4306+ ++ san |= [a=@s] ^- @rs (san:ma a)
4320+Produces the sign of `a`.
4333+ ++ sig |= [a=@rs] ^- ? (sig:ma a)
4342+ > (sig:rs .-3.43e2)
4351+Produces the exponent of `a`.
4364+ ++ exp |= [a=@rs] ^- @s (exp:ma a)
4370+ > (exp:rs .-3.43e2)
4379+Rounds `a` to the nearest integer.
4392+ ++ toi |= [a=@rs] ^- (unit @s) (toi:ma a)
4398+ > (toi:rs .-3.43e2)
4405+`@rs` to decimal float
4407+Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
4408+accurate results for rounded floats.
4421+ ++ drg |= [a=@rs] ^- dn (drg:ma a)
4427+ > (drg:rs .-3.43e2)
4428+ [%d s=%.n e=--0 a=343]
4434+Decimal float to `@rs`
4436+Converts `a` from `dn` to `@rs`.
4449+ ++ grd |= [a=dn] ^- @rs (grd:ma a)
4456+ > (grd:rs [%d s=%.n e=--0 a=343])
4463+Quadruple-precision fp
4465+A container core for operations related to quadruple-precision binary floats.
4467+`++rq` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
4468+down (`$d`), and round to zero (`$z`).
4476+ |_ r=$?($n $u $d $z)
4483+Instantiates the core `ff`, giving values to its samples based on the
4484+configuration of the `rq` core.
4490+ %*(. ff w 15, p 112, b --16.383, r r)
4498+Converts `a` from `@rq` to `fn`.
4502+`a` is a `@rq`, a quad-precision float.
4512+ |= [a=@rq] (sea:ma a)
4518+ > (sea:rq .~~~1.05102e5)
4519+ [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272]
4527+Converts `a` from `fn` to `@rq`.
4535+A `@rq`, a quad-precision float.
4541+ |= [a=n] ^- @rq (bit:ma a)
4547+ > (bit:rq [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272])
4556+Produces the sum of `a` plus `b`.
4560+`a` is a `@rq`, a quad-precision float.
4572+ |= [a=@rq b=@rq] ^- @rq
4580+ > (add:rq .~~~-1.821e5 .~~~1.05102e5)
4589+Produces the difference of `a` minus `b`.
4593+`a` is a `@rq`, a quad-precision float.
4605+ |= [a=@rq b=@rq] ^- @rq
4613+ > (sub:rq .~~~1.821e5 .~~~1.05102e5)
4616+ > (sub:rq .~~~1.821e5 .~~~-1.05102e5)
4625+Produces the product of `a` times `b`.
4629+`a` is a `@rq`, a quad-precision float.
4641+ |= [a=@rq b=@rq] ^- @rq
4649+ > (mul:rq .~~~1.821e5 .~~~-1.05102e5)
4658+Produces the product of `a` divided by `b`.
4662+`a` is a `@rq`, a quad-precision float.
4674+ |= [a=@rq b=@rq] ^- @rq
4682+ > (div:rq .~~~1.821e5 .~~~1.05102e3)
4683+ .~~~1.732602614602957127361991208540275e2
4691+Produces the sum of `c` plus the product of `a` multiplied by `b`;
4696+`a` is a `@rq`, a quad-precision float.
4710+ |= [a=@rq b=@rq c=@rq] ^- @rq
4718+ > (fma:rq .~~~1.821e5 .~~~-1.05102e2 .~~~6.2044e7)
4727+Produces the square root of `a`.
4731+`a` is a `@rq`, a quad-precision float.
4749+ > (sqt:rq .~~~6.2044e7)
4750+ .~~~7.876801381271461258959876570289002e3
4758+Tests whether `a` is less than `b`.
4762+`a` is a `@rq`, a quad-precision float.
4783+ > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4786+ > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4795+Tests whether `a` is less than or equal to `b`.
4799+`a` is a `@rq`, a quad-precision float.
4819+ > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4822+ > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4825+ > (lte:rq .~~~1.2044e7 .~~~1.2044e7)
4834+Tests whether `a` is equal to `b`.
4838+`a` is a `@rq`, a quad-precision float.
4858+ > (equ:rq .~~~1.2044e7 .~~~1.2044e7)
4861+ > (equ:rq .~~~2.2044e7 .~~~1.2044e7)
4868+Greater than or equal
4870+Tests whether `a` is greater than or equal to `b`.
4874+`a` is a `@rq`, a quad-precision float.
4894+ > (gte:rq .~~~1.2044e7 .~~~1.2044e7)
4897+ > (gte:rq .~~~2.2044e7 .~~~1.2044e7)
4900+ > (gte:rq .~~~1.2044e7 .~~~2.2044e7)
4907+Tests whether `a` is greater than `b`.
4911+`a` is a `@rq`, a quad-precision float.
4931+ > (gth:rq .~~~1.2044e7 .~~~1.2044e7)
4934+ > (gth:rq .~~~2.2044e7 .~~~1.2044e7)
4937+ > (gth:rq .~~~1.2044e7 .~~~2.2044e7)
4944+Unsigned integer to `@rq`
4946+Converts `@` from an unsigned integer to `@rq`.
4950+`a` is a `@u`, an unsigned integer.
4954+A `@rq`, a quad-precision float.
4959+ ++ sun |= [a=@u] ^- @rq (sun:ma a)
4972+Signed integer to `rq`
4974+Converts `@` from a signed integer to `@rq`.
4978+`a` is a `@s`, a signed integer.
4982+A `@rq`, a quad-precision float.
4987+ ++ san |= [a=@s] ^- @rq (san:ma a)
5002+Produces the sign of `a`.
5006+`a` is a `@rq`, a quad-precision float.
5015+ ++ sig |= [a=@rq] ^- ? (sig:ma a)
5021+ > (sig:rq .~~~-2.05e2)
5030+Gets the exponent of `a`.
5034+`a` is a `@rq`, a quad-precision float.
5038+A `@s`, a signed integer.
5043+ ++ exp |= [a=@rq] ^- @s (exp:ma a)
5049+ > (exp:rq .~~~-2.05e2)
5058+Rounds `a` to the nearest integer.
5062+`a` is a `@rq`, a quad-precision float.
5071+ ++ toi |= [a=@rq] ^- (unit @s) (toi:ma a)
5077+ > (toi:rq .~~~-2.085e2)
5080+ > (toi:rq .~~~-2.08e2)
5087+`@rq` to decimal float
5089+Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5090+accurate results for rounded floats.
5094+`a` is a `@rq`, a quad-precision float.
5103+ ++ drg |= [a=@rq] ^- dn (drg:ma a) :: @rq to decimal float
5109+ > (drg:rq .~~~-2.085e2)
5110+ [%d s=%.n e=-1 a=2.085]
5112+ > (drg:rq .~~~-2.08e2)
5113+ [%d s=%.n e=--0 a=208]
5119+Decimal float to `@rq`
5121+Converts `a` from `dn` to `@rq`.
5131+A `@rq`, a quad-precision float.
5136+ ++ grd |= [a=dn] ^- @rq (grd:ma a)
5143+ > (grd:rq [%d s=%.n e=--0 a=343])
5152+A container core for operations related to half-precision binary floats.
5154+`++rh` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
5155+down (`$d`), and round to zero (`$z`).
5163+ |_ r=$?($n $u $d $z)
5171+Instantiates the core `ff`, giving values to its samples based on the
5172+configuration of the `rh` core.
5178+ %*(. ff w 5, p 10, b --15, r r)
5186+Converts `a` from `@rh` to `fn`.
5190+`a` is a `@rh`, a half-precision float.
5200+ |= [a=@rh] (sea:ma a)
5206+ > (sea:rh .~~1.22e-5)
5207+ [%f s=%.y e=-24 a=205]
2−navhome: /docs/
5211+### `++bit:rh`
5215+Converts `a` from `fn` to `@rh`.
5223+A `@rh`, a half-precision float.
5229+ |= [a=fn] ^- @rh (bit:ma a)
5235+ > (bit:rh [%f s=%.y e=-24 a=205])
5242+Produces the sum of `a` plus `b`.
6−# 3b: floating point
5244+#### Accepts
5246+`a` is a `@rh`, a half-precision float.
5258+ |= [a=@rh b=@rh] ^- @rh
5266+ > (add:rh .~~1.82e2 .~~1.02e2)
5275+Produces the difference of `a` minus `b`.
5279+`a` is a `@rh`, a half-precision float.
5291+ |= [a=@rh b=@rh] ^- @rh
5299+ > (sub:rh .~~1.821e2 .~~1.051e2)
5302+ > (sub:rh .~~1.821e2 .~~6.051e2)
5311+Produces the product of `a` times `b`.
5315+`a` is a `@rh`, a quad-precision float.
5327+ |= [a=@rh b=@rh] ^- @rh
5335+ > (mul:rh .~~1.821e1 .~~-1.05102e2)
5344+Produces the product of `a` divided by `b`.
5348+`a` is a `@rh`, a half-precision float.
5360+ |= [a=@rh b=@rh] ^- @rh
5368+ > (div:rh .~~1.821e3 .~~1.05102e2)
5377+Produces the sum of `c` plus the product of `a` multiplied by `b`;
5382+`a` is a `@rh`, a half-precision float.
5396+ |= [a=@rh b=@rh c=@rh] ^- @rh
5404+ > (fma:rh .~~1.821e4 .~~-1.05102e2 .~~6.2044e3)
5413+Produces the square root of `a`.
5417+`a` is a `@rh`, a half-precision float.
5435+ > (sqt:rh .~~6.24e4)
5444+Tests whether `a` is less than `b`.
5448+`a` is a `@rh`, a half-precision float.
5468+ > (lth:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5471+ > (lth:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5480+Tests whether `a` is less than or equal to `b`.
5484+`a` is a `@rh`, a half-precision float.
5504+ > (lth:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5507+ > (lth:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5510+ > (lte:rh .~~1.2e3 .~~1.2e3)
5519+Tests whether `a` is equal to `b`.
5523+`a` is a `@rh`, a half-precision float.
5543+ > (equ:rh .~~1.24e4 .~~1.24e4)
5546+ > (equ:rh .~~2.24e4 .~~1.24e4)
5553+Greater than or equal
5555+Tests whether `a` is greater than or equal to `b`.
5559+`a` is a `@rh`, a half-precision float.
5579+ > (gte:rh .~~1.24e4 .~~1.24e4)
5582+ > (gte:rh .~~2.24e4 .~~1.24e4)
5585+ > (gte:rh .~~1.24e4 .~~2.24e4)
5592+Tests whether `a` is greater than `b`.
5596+`a` is a `@rh`, a half-precision float.
5616+ > (gth:rh .~~1.24e4 .~~1.244e4)
5619+ > (gth:rh .~~2.24e4 .~~1.24e4)
5622+ > (gth:rh .~~1.24e4 .~~2.24e4)
5629+Unsigned integer to `@rh`
5631+Converts `@` from an unsigned integer to `@rh`.
5635+`a` is a `@u`, an unsigned integer.
5639+A `@rh`, a half-precision float.
5644+ ++ sun |= [a=@u] ^- @rh (sun:ma a)
5657+Signed integer to `@rh`
5659+Converts `@` from a signed integer to `@rh`.
5663+`a` is a `@s`, a signed integer.
5667+A `@rh`, a half-precision float.
5672+ ++ san |= [a=@s] ^- @rh (san:ma a)
5687+Produces the sign of `a`.
5691+`a` is a `@rh`, a half-precision float.
5700+ ++ sig |= [a=@rh] ^- ? (sig:ma a)
5706+ > (sig:rh .~~-2.05e2)
5715+Gets the exponent of `a`.
5719+`a` is a `@rh`, a half-precision float.
5723+A `@s`, a signed integer.
5728+ ++ exp |= [a=@rh] ^- @s (exp:ma a)
5734+ > (exp:rh .~~-2.05e2)
5743+Rounds `a` to the nearest integer.
5747+`a` is a `@rh`, a half-precision float.
5756+ ++ toi |= [a=@rh] ^- (unit @s) (toi:ma a)
5762+ > (toi:rh .~~-2.085e2)
5765+ > (toi:rh .~~-2.08e2)
5772+`@rh` to decimal float
5774+Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5775+accurate results for rounded floats.
5779+`a` is a `@rh`, a half-precision float.
5788+ ++ drg |= [a=@rh] ^- dn (drg:ma a)
5794+ > (drg:rh .~~-2.085e2)
5795+ [%d s=%.n e=-1 a=2.085]
5797+ > (drg:rh .~~-2.08e2)
5798+ [%d s=%.n e=--0 a=208]
5804+Decimal float to `@rh`
5806+Converts `a` from `dn` to `@rh`.
5816+A `@rh`, a a half-precision float.
5821+ ++ grd |= [a=dn] ^- @rh (grd:ma a)
5828+ > (grd:rh [%d s=%.n e=--0 a=343])