on c19bc7a help sign in
5832 lines 83 kB history raw
1:- :~ navhome/'/docs/'
2 sort/'22'
3 title/'3b: Floating Point'
4 ==
6;>
8# 3b: floating point
10### `++fn`
12Float
14A mold for the floating-point arithmetic using the base of two, the formula is
15`(-1)^s * a * 2^e`.
17Produces either a float (`$f`), an infinity of other sign (`$i`),
18or not-a-number (`$n`). `s` refers to sign, the `flag`s `&` or `|`; `e` to
19exponent, a signed decimal; and `a` to the significand, an unsigned integer.
21#### Source
23```
24 ++ fn
25 $% [$f s=? e=@s a=@u]
26 [$i s=?]
27 [$n ~]
28 ==
29```
31### Examples
33```
34 > *fn
35 [%n ~]
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 &])
41 [%i s=%.y]
43 > (add:fl [%n ~] [%i |])
44 [%n ~]
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]
48```
51---
52### `++dn`
54Decimal float
56A mold for the floating-point arithmetic using the base of 10; the formula is
57`(-1)^s * a *10^e`.
59Valid 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;
61and `a` to the significand, an unsigned integer.
63```
64 ++ dn
65 $% [$d s=? e=@s a=@u]
66 [$i s=?]
67 [$n ~]
68 ==
69```
71#### Examples
73```
74 > `dn`[%d & --0 17.163.091.968]
75 [%d s=%.y e=--0 a=17.163.091.968]
77 > `dn`[%i s=%.y]
78 [%i s=%.y]
80 > `dn`[%n ~]
81 [%n ~]
82```
84---
85### `++rn`
87Parsed decimal float
89A mold for the floating-point arithmetic using the base of 10; the formula is
90`(-1)^s * a *10^e`.
92Produces either a parsed float (`$d`), infinity of either sign (`$i`), or
93not-a-number (`$n`).
95#### Source
97```
98 $% [$d a=? b=[c=@ [d=@ e=@] f=? i=@]]
99 [$i a=?]
100 [$n ~]
101 ==
102```
104#### Examples
106```
107 > `rn`[%d | [2 [3 4] | 17.163]]
108 [%d a=%.n b=[c=2 [d=3 e=4] f=%.n i=17.163]]
109```
111---
112### `++fl`
114Arbitrary-precision floating-point
116Container arm for floating-point arithmetic functions.
118- Precision (`p`): number of bits in the significand; must be at least 2.
119 Default is 113.
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.
122 Default is 32.988.
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`.
128#### Source
130```
131 ++ fl
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]
134 =>
135 ~% %cofl +> ~
136 |%
137```
139---
140### `++rou:fl`
142Round
144Rounds `a` to a the nearest float that can be represented with a 113-bit
145significand. There is no term to sign the significand, meaning that a positive
146sign will always be produced.
148#### Accepts
150`a` is a cell of a signed integer and an unsigned integer.
152#### Produces
154An `fn`.
156#### Source
158```
159 ++ rou
160 |= [a=[e=@s a=@u]] ^- fn (rau a &)
161```
163#### Examples
165```
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]
178```
180---
181### `++rau:fl`
183Various roundings
185Rounds `a` based on what the state of of `r` in the core contained in `fl`. `t`
186is a sticky bit that represents a value less than ULP(a) = 2^(e.a) when passed
187to `lug:fl`.
189#### Accepts
191`a` is a cell of a signed integer and an unsigned integer.
193`t` is a `flag`.
195#### Produces
197An `fn`.
199#### Source
201```
202 ++ rau
203 |= [a=[e=@s a=@u] t=?] ^- fn
204 ?- r
205 $z (lug %fl a t) $d (lug %fl a t)
206 $a (lug %ce a t) $u (lug %ce a t)
207 $n (lug %ne a t)
208 ==
209```
211#### Examples
213```
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]
216```
219#### Discussion
221See `lug:fl` for possible rounding operations.
223---
224### `++add:fl`
226Add
228Produces 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).
231There is no term to sign the significands, so a positive sign will always be
232produced.
234#### Accepts
236`a` is an `fn`.
238`b` is an `fn`
240`e` is a `flag`.
242#### Produces
244An `fn`.
246#### Source
248```
249 ++ add
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
253 ?: e
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
260 ?- r
261 $z (lug %fl a &) $d (lug %fl a &)
262 $a (lug %lg a &) $u (lug %lg a &)
263 $n (lug %na a &)
264 ==
265 (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)])
266```
268#### Examples
270```
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]
276```
278---
279### `++sub:fl`
281Subtract
283Produces the difference of `a` minus `b.` `e` is used to choose between an exact
284result (any-sized significand) or a rounded result (113-bit significand).
286#### Accepts
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.
292`e` is a `flag`.
294#### Produces
296An `fn`.
298#### Source
300```
301 ++ sub
302 |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
303 =+ q=(dif:si e.a e.b)
304 |- ?. (syn:si q)
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))
311 ?- r
312 $z (lug %sm a &) $d (lug %sm a &)
313 $a (lug %ce a &) $u (lug %ce a &)
314 $n (lug %nt a &)
315 ==
316 =+ j=(lsh 0 (abs:si q) a.a)
317 |- ?. (gte j a.b)
318 (fli $(a.b j, j a.b, r swr))
319 =+ i=(^sub j a.b)
320 ?~ i [%f & zer]
321 ?: e [%f & e.b i] (rou [e.b i])
322```
324#### Examples
326```
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]
332```
334---
335### `++mul:fl`
337Multiply
339Produces the product of `a` multiplied by `b`. There is no term to sign the
340significands, so a positive sign will always be produced.
342#### Accepts
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.
348#### Produces
350An `fn`.
352#### Source
354```
355 ++ mul
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))
358```
360#### Examples
362```
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]
365```
367---
368### `++div:fl`
370Divide
372Produces the quotient of `a` divided by `b`. There is no term to sign the
373significands, so a positive sign will always be produced.
375#### Accepts
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.
381#### Produces
383An `fn`.
385#### Source
387```
388 ++ div
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))
396```
398#### Examples
400```
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]
403```
405---
406### `++sqt:fl`
408Square root
410Produces the square root of `a`.
412#### Accepts
414`a` is a cell of a signed integer and an unsigned integer.
416#### Produces
418An `fn`.
420#### Source
422```
423 ++ sqt
424 |= [a=[e=@s a=@u]] ^- fn
425 =. a
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)) -
429 (^add - 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))
433```
435#### Examples
437```
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]
440```
442---
443### `++lth:fl`
445Less than
447Tests if `a` is less than `b`.
449#### Accepts
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.
455#### Produces
457An `flag`.
459#### Source
461```
462 ++ lth
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)
470```
472#### Examples
474```
475 > (^lth:fl [-4 684] [--0 35])
476 %.n
478 > (^lth:fl [-4 684] [--0 90])
479 %.y
480```
482---
483### `++equ:fl`
485Equals
487Tests if `a` is equal to `b`.
489#### Accepts
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.
495#### Produces
497A `flag`.
499#### Source
501```
502 ++ equ
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)
508```
510#### Examples
512```
513 > (^equ:fl [-4 480] [-0 50])
514 %.n
516 > (^equ:fl [-4 480] [-0 30])
517 %.y
518```
520---
521### `++ibl:fl`
523Integer binary logarithm
525Produces the lowest power to which the number 2 must be raised to obtain `a` or
526greater.
528#### Accepts
530`a` is a cell of a signed integer and an unsigned integer.
532#### Produces
534A signed integer.
536#### Source
538```
539 ++ ibl
540 |= [a=[e=@s a=@u]] ^- @s
541 (sum:si (sun:si (dec (met 0 a.a))) e.a)
542```
544#### Examples
546```
547 > (ibl:fl [-18 342.602.577])
548 --10
549```
551---
552### `++uni:fl`
554Change representation to odd
556Produces another representation of the floating point `a` where the significand
557is odd. Every floating-point number has a unique representation of this kind. If
558the significand of `a` is already odd, nothing changes.
560#### Accepts
562`a` is a cell of a signed integer and an unsigned integer.
564#### Produces
566A cell of a signed integer and an unsigned integer.
568#### Source
570```
571 ++ uni
572 |= [a=[e=@s a=@u]]
573 |- ?: =((end 0 1 a.a) 1) a
574 $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1))
575```
577#### Examples
579```
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]
585```
587---
588### `++xpd:fl`
590Expand
592Produces the fully precise form of `a`, or the denormalized form of `a`.
594#### Accepts
596`a` is a cell of a signed integer and an unsigned integer.
598#### Produces
600A cell of a signed integer and an unsigned integer.
602#### Sources
604```
605 ++ xpd
606 |= [a=[e=@s a=@u]]
607 =+ ma=(met 0 a.a)
608 ?: (gte ma prc) a
609 =+ ?: =(den %i) (^sub prc ma)
610 =+ ^= q
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))
615```
617#### Examples
619```
620 > (xpd:fl [--3 12])
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]
628```
630---
631### `++lug:fl`
633Central rounding mechanism
635Performs various rounding operations on `a`. An operation is chosen based on the
636value selected for `t`. `s` is a sticky bit that represents a value less than
637ULP(a) = 2^(e.a)
639Possible rounding operations:
640- Floor (`$fl`)
641- Ceiling (`$ce`)
642- Smaller (`$sm`)
643- Larger (`$lg`)
644- Nearest (`$ne`) -- Rounds ties away from 0 if the number is even, rounds
645 toward 0 if the number is odd.
647#### Accepts
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.
653`s` is a flag.
655#### Produces
657An `fn`.
659#### Source
661```
662 ::
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)
667 ::
668 ++ lug
669 ~/ %lug
670 |= [t=$?($fl $ce $sm $lg $ne $na $nt) a=[e=@s a=@u] s=?] ^- fn
671 ?< =(a.a 0)
672 =-
673 ?. =(den %f) - :: flush denormals
674 ?. ?=([$f *] -) -
675 ?: =((met 0 ->+>) prc) - [%f & zer]
676 ::
677 =+ m=(met 0 a.a)
678 ?> |(s (gth m prc)) :: require precision
679 =+ ^= q %+ max
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))
685 ::
686 ?~ a.a
687 ?< =(den %i)
688 ?- t
689 $fl [%f & zer]
690 $sm [%f & zer]
691 $ce [%f & spd]
692 $lg [%f & spd]
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)]
698 ==
699 ::
700 =. a (xpd a)
701 ::
702 =. a
703 ?- t
704 $fl a
705 $lg a(a +(a.a))
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))
712 $ne ?~ b a
713 =+ y=(bex (dec q))
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))
717 $na ?~ b a
718 =+ y=(bex (dec q))
719 ?: (^lth b y) a a(a +(a.a))
720 $nt ?~ b a
721 =+ y=(bex (dec q))
722 ?: =(b y) ?: s a a(a +(a.a))
723 ?: (^lth b y) a a(a +(a.a))
724 ==
725 ::
726 =. a ?. =((met 0 a.a) +(prc)) a
727 a(a (rsh 0 1 a.a), e (sum:si e.a --1))
728 ?~ a.a [%f & zer]
729 ::
730 ?: =(den %i) [%f & a]
731 ?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp
732 ::
733```
735---
736### `++drg:fl`
738Get printable decimal
740Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
741accurate results for rounded floats.
743#### Accepts
745`a` is a cell of a signed integer and an unsigned integer.
747#### Produces
749A cell of a signed integer and an unsigned integer.
751#### Source
753```
754 ++ drg
755 ~/ %drg
756 |= [a=[e=@s a=@u]] ^- [@s @u]
757 ?< =(a.a 0)
758 =. a (xpd a)
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)
762 =+ mp=mn
763 => ?.
764 ?& =(a.a (bex (dec prc))) :: if next smallest
765 |(!=(e.a emn) =(den %i)) :: float is half ULP,
766 == :: tighten lower bound
767 .
768 %= .
769 mp (lsh 0 1 mp)
770 r (lsh 0 1 r)
771 s (lsh 0 1 s)
772 ==
773 =+ [k=--0 q=(^div (^add s 9) 10)]
774 |- ?: (^lth r q)
775 %= $
776 k (dif:si k --1)
777 r (^mul r 10)
778 mn (^mul mn 10)
779 mp (^mul mp 10)
780 ==
781 |- ?: (gte (^add (^mul r 2) mp) (^mul s 2))
782 $(s (^mul s 10), k (sum:si k --1))
783 =+ [u=0 o=0]
784 |- :: r/s+o = a*10^-k
785 =+ v=(dvr (^mul r 10) s)
786 => %= .
787 k (dif:si k --1)
788 u p.v
789 r q.v
790 mn (^mul mn 10)
791 mp (^mul mp 10)
792 ==
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))
797 ==
798 ?: &(!l !h)
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))
802 [k o]
803```
805#### Examples
807```
808 > (sun:fl 218.116)
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])
811 [--0 218.116]
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]
817```
819---
820### `++toj:fl`
822Round to integer
824Rounds float `a` to the nearest decimal float with an exponent of 0.
826#### Accepts
828`a` is a cell of a signed integer and an unsigned integer.
830#### Produces
832An `fn`.
834#### Source
836```
837 ++ toj
838 |= [a=[e=@s a=@u]] ^- fn
839 ?. =((cmp:si e.a --0) -1) [%f & a]
840 =+ x=(abs:si e.a)
841 =+ y=(rsh 0 x a.a)
842 ?: |(=(r %d) =(r %z)) [%f & --0 y]
843 =+ z=(end 0 x a.a)
844 ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))]
845 =+ i=(bex (dec x))
846 ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y]
847 ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)]
848```
850#### Examples
852```
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]
858```
860---
861### `++ned:fl`
863Require float
865Produces `a` if `a` is a is of floating-point representation. If `a` is another
866case of `fn`, such as infinity or not-a-number, a crash is produced.
868#### Accepts
870`a` is an `fn`.
872#### Produces
874A cell of a signed integer and an unsigned integer.
876#### Source
878```
879 ++ ned
880 |= [a=fn] ^- [$f s=? e=@s a=@u]
881 ?: ?=([$f *] a) a
882 ~_ leaf+"need-float"
883 !!
884```
886#### Examples
889```
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]
893 > (ned:fl [%n ~])
894 ! need-float
895 ! exit
897 > (ned:fl [%i |])
898 ! need-float
899 ! exit
900```
902---
903### `++shf:fl`
905Shift power
907Multiplies `a` by 2 to the `b` power without rounding. This results in shifting
908the exponent term by `b`.
910#### Accepts
912`a` is an `fn`.
914`b` is a signed integer.
916#### Produces
918An `fn`.
920#### Source
922```
923 ++ shf
924 |= [a=fn b=@s]
925 ?: |(?=([$n *] a) ?=([$i *] a)) a
926 a(e (sum:si e.a b))
927```
929#### Examples
931```
932 > (shf:fl [[%f & -2 7] --2])
933 [%f s=%.y e=--0 a=7]
935 > (shf:fl [[%f & -2 7] -2])
936 [%f s=%.y e=-4 a=7]
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]
940```
942---
943### `++fli:fl`
945Flip sign
947Produces `a` with its signed changed from positive to negative, or vice versa.
949#### Accepts
951`a` is an `fn`.
953#### Produces
955An `fn`.
957#### Source
959```
960 ++ fli
961 |= [a=fn] ^- fn
962 ?-(-.a $f a(s !s.a), $i a(s !s.a), $n a)
963```
965#### Examples
967```
968 > (fli:fl [%f %.y -2 7])
969 [%f s=%.n e=-2 a=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]
976```
978---
979### `++swr:fl`
981Switch rounding
983Switches the rounding mode of `r:fl`.
985#### Source
987```
988 ++ swr ?+(r r $d %u, $u %d)
989```
991#### Examples
993```
994 > r:fl
995 %n
996 > swr:fl
997 %n
999 > =new-fl fl :: new fl core with changed state
1000 > =new-fl new-fl(r %u)
1001 > swr:new-fl
1002 %d
1003```
1005---
1006### `++prc:fl`
1008Force precision of 2 or greater
1010Produces `p`, the core's precision, if `p` is greater than or equal to 2.
1011Otherwise, a crash is produced.
1013#### Source
1015```
1016 ++ prc ?>((gth p 1) p)
1017```
1019#### Examples
1021```
1022 > prc:fl
1023 113
1025 > =new-fl fl
1026 > =new-fl new-fl(p 1)
1027 > prc:new-fl
1028 ! exit
1030 > =new-fl new-fl(p 2)
1031 > prc:new-fl
1033```
1035---
1036### `++den:fl`
1038Behavior
1040Produces `d:fl`. Denormalizes if `d:fl` is `%d`. Flushes denormals to zero if
1041`d:fl` is `%f`.
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`.
1047The default value of `d` is `%d`.
1049#### Source
1051```
1052 ++ den d
1053```
1055#### Examples
1057```
1058 > den:fl
1059 %d
1061 > =new-fl fl
1062 > =new-fl new-fl(d %f)
1063 > den:new-fl
1064 %f
1065```
1067---
1068### `++emn:si`
1070Minimum exponent
1072Produces `v:fl`, the minimum exponent. The default minimum exponent is -16.494.
1074#### Source
1076```
1077 ++ emn v
1078```
1080#### Examples
1082```
1083 > emn:fl
1084 -16.494
1085```
1087---
1088### `++emx:fl`
1090Maximum exponent
1092Returns the maximum exponent of `fl`. The default maximum exponent is --16.494.
1094#### Source
1096```
1097 ++ emx (sum:si emn (sun:si w))
1098```
1100#### Examples
1102```
1103 > `@u`emx:fl
1104 32.542
1105```
1107---
1108### `++spd:fl`
1110Smallest denormal
1112Produces the smallest possible denormalized float.
1114#### Source
1116```
1117 ++ spd [e=emn a=1]
1118```
1120#### Examples
1122```
1123 > spd:fl
1124 [e=-16.494 a=1]
1125```
1127---
1128### `++spn:fl`
1130Smallest normal
1132Produces the smallest representable normal float.
1134#### Source
1136```
1137 ++ spn [e=emn a=(bex (dec prc))]
1138```
1140#### Examples
1142```
1143 > spn:fl
1144 [e=-16.494 a=5.192.296.858.534.827.628.530.496.329.220.096]
1145```
1147---
1148### `++lfn:fl`
1150Largest normal
1152Produces the largest representable normal float.
1154#### Source
1156```
1157 ++ lfn [e=emx a=(fil 0 prc 1)]
1158```
1160#### Examples
1162```
1163 > lfn:fl
1164 [e=--16.271 a=10.384.593.717.069.655.257.060.992.658.440.191]
1165```
1167---
1168### `++lfe:fl`
1170Maximum
1172Produces the sum of `emx:fl` plus `prc:fl`.
1174#### Source
1176```
1177 ++ lfe (sum:si emx (sun:si prc)) :: 2^lfe is > than all
1178```
1180#### Examples
1182```
1183 > lfe:fl
1184 --16.384
1185```
1187---
1188### `++zer:fl`
1190Zero
1192Produces zero represented as a float.
1194#### Source
1196```
1197 ++ zer [e=--0 a=0]
1198 --
1199 |%
1200```
1202#### Examples
1204```
1205 > zer:fl
1206 [e=--0 a=0]
1207```
1209---
1210### `++rou:fl`
1212Round
1214Rounds `a`. The way in which `a` is rounded depends on the value of `r:fl`.
1216#### Accepts
1218`a` is an `fn`.
1220#### Produes
1222An `fn`.
1224#### Source
1226```
1227 ++ rou
1228 |= [a=fn] ^- fn
1229 ?. ?=([$f *] a) a
1230 ?~ a.a [%f s.a zer]
1231 ?: s.a (^rou +>.a)
1232 =.(r swr (fli (^rou +>.a)))
1233```
1235#### Examples
1237```
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]
1250```
1252---
1253### `++syn:fl`
1255Get sign
1257Produces the sign of `a`.
1259#### Accepts
1261`a` is an `fn`.
1263#### Produes
1265An `fn`.
1267#### Source
1269```
1270 ++ syn
1271 |= [a=fn] ^- ?
1272 ?-(-.a $f s.a, $i s.a, $n &)
1273```
1275#### Examples
1277```
1278 > (syn:fl (sun:fl 106))
1279 %.y
1281 > (syn:fl [%f | --0 106])
1282 %.n
1283```
1285---
1286### `++abs:fl`
1288Absolute value
1290Produces the absolute value of `a`.
1292#### Accepts
1294`a` is an `fn`.
1296#### Produes
1298An `fn`.
1300#### Sources
1302```
1303 ++ abs
1304 |= [a=fn] ^- fn
1305 ?: ?=([$f *] a) [%f & e.a a.a]
1306 ?: ?=([$i *] a) [%i &] [%n ~]
1307```
1309#### Examples
1311```
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]
1317```
1319---
1320### `++add:fl`
1322Add
1324Produces the sum of `a` plus `b`.
1326#### Accepts
1328`a` is an `fn`.
1330`b` is an `fn`.
1332#### Produces
1334An `fn`.
1336#### Source
1338```
1339 ++ add
1340 |= [a=fn b=fn] ^- fn
1341 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1342 ?: |(?=([$i *] a) ?=([$i *] b))
1343 ?: &(?=([$i *] a) ?=([$i *] b))
1344 ?: =(a b) a [%n ~]
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]
1349 %- |= [a=fn]
1350 ?. ?=([$f *] a) a
1351 ?. =(a.a 0) a
1352 [%f !=(r %d) zer]
1353 ?: =(s.a s.b)
1354 ?: s.a (^add +>.a +>.b |)
1355 =.(r swr (fli (^add +>.a +>.b |)))
1356 ?: s.a (^sub +>.a +>.b |)
1357 (^sub +>.b +>.a |)
1358```
1360#### Examples
1362```
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]
1365```
1367---
1368### `++ead:fl`
1370Exact add
1372Produces the exact sum of `a` plus `b`.
1374#### Accepts
1376`a` is an `fn`.
1378`b` is an `fn`.
1380#### Produces
1382An `fn`.
1384#### Source
1386```
1387 ++ ead
1388 |= [a=fn b=fn] ^- fn
1389 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1390 ?: |(?=([$i *] a) ?=([$i *] b))
1391 ?: &(?=([$i *] a) ?=([$i *] b))
1392 ?: =(a b) a [%n ~]
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]
1397 %- |= [a=fn]
1398 ?. ?=([$f *] a) a
1399 ?. =(a.a 0) a
1400 [%f !=(r %d) zer]
1401 ?: =(s.a s.b)
1402 ?: s.a (^add +>.a +>.b &)
1403 (fli (^add +>.a +>.b &))
1404 ?: s.a (^sub +>.a +>.b &)
1405 (^sub +>.b +>.a &)
1406 ::
1407```
1409#### Examples
1411```
1412 > (ead:fl [%f & --0 106] [%f | --3 55])
1413 [%f s=%.n e=--0 a=334]
1414```
1416---
1417### `++sub:fl`
1419Subtract
1421Produces the difference of `a` minus `b`.
1423#### Accepts
1425`a` is an `fn`.
1427`b` is an `fn`.
1429#### Produces
1431An `fn`.
1433#### Source
1435```
1436 ++ sub
1437 |= [a=fn b=fn] ^- fn (add a (fli b))
1438```
1440#### Examples
1442```
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]
1445```
1447---
1448### `++mul:fl`
1450Multiply
1452Produces the product of `a` multiplied by `b`.
1454#### Accepts
1456`a` is an `fn`.
1458`b` is an `fn`.
1460#### Produces
1462An `fn`.
1464#### Source
1466```
1467 ++ mul
1468 |= [a=fn b=fn] ^- fn
1469 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1470 ?: ?=([$i *] a)
1471 ?: ?=([$i *] b)
1472 [%i =(s.a s.b)]
1473 ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1474 ?: ?=([$i *] 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)))
1479```
1481---
1482### `++emu:fl`
1484Exact multiply
1486Produces the exact product of `a` multiplied by `b`.
1488#### Accepts
1490`a` is an `fn`.
1492`b` is an `fn`.
1494#### Produces
1496An `fn`.
1498#### Examples
1500```
1501 ++ emu
1502 |= [a=fn b=fn] ^- fn
1503 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1504 ?: ?=([$i *] a)
1505 ?: ?=([$i *] b)
1506 [%i =(s.a s.b)]
1507 ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1508 ?: ?=([$i *] 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)]
1512```
1514---
1515### `++div:fl`
1517Divide
1519Produces the quotient of `a` divided by `b`.
1521#### Accepts
1523`a` is an `fn`.
1525`b` is an `fn`.
1527#### Produces
1529An `fn`.
1531#### Divide
1533```
1534 ++ div
1535 |= [a=fn b=fn] ^- fn
1536 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1537 ?: ?=([$i *] a)
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)))
1544```
1546---
1547### `++fma:fl`
1549Fused multiply-add
1551Produces the sum of `c` plus the product of `a` multiplied by `b`;
1552`(a * b) + c`.
1554#### Accepts
1556`a` is an `fn`.
1558`b` is an `fn`.
1560`c` is an `fn`.
1562#### Produces
1564An `fn`.
1566#### Source
1568```
1569 ++ fma
1570 |= [a=fn b=fn c=fn] ^- fn
1571 (add (emu a b) c)
1572```
1574#### Examples
1576```
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]=
1579```
1581---
1582### `++sqt:fl`
1584Square root
1586Produces the square root of `a`.
1588#### Accepts
1590`a` is an `fn`.
1592#### Produces
1594An `fn`.
1596#### Source
1598```
1599 ++ sqt
1600 |= [a=fn] ^- fn
1601 ?: ?=([$n *] a) [%n ~]
1602 ?: ?=([$i *] a) ?:(s.a a [%n ~])
1603 ?~ a.a [%f s.a zer]
1604 ?: s.a (^sqt +>.a) [%n ~]
1605```
1607#### Examples
1609```
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]
1612```
1614---
1615### `++inv:fl`
1617Inverse
1619Produces the inverse of `a` by dividing `1` by `a`.
1621#### Accepts
1623`a` is an `fn`.
1625#### Produces
1627An `fn`.
1629#### Source
1631```
1632 ++ inv
1633 |= [a=fn] ^- fn
1634 (div [%f & --0 1] a)
1635```
1637#### Examples
1639```
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]
1654```
1656---
1657### `++sun:fl`
1659Signed integer to float
1661Produces `a` in floating-point representation.
1663#### Accepts
1665`a` is an unsigned integer.
1667#### Produces
1669An `fn`.
1671#### Source
1673```
1674 ++ sun
1675 |= [a=@u] ^- fn
1676 (rou [%f & --0 a])
1677```
1679#### Examples
1681```
1682 > (sun:fl 0)
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]
1688 > (sun:fl -100)
1689 ! exit
1690```
1692---
1693### `++san:fl`
1695Signed integer to float
1697Produces the floating-point representation of `a`, an unsigned integer.
1699#### Accepts
1701`a` is an unsigned integer.
1703#### Produces
1705An `fn`.
1707#### Source
1709```
1710 ++ san
1711 |= [a=@s] ^- fn
1712 =+ b=(old:si a)
1713 (rou [%f -.b --0 +.b])
1714```
1716#### Examples
1718```
1719 > (san:fl --100)
1720 [%f s=%.y e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1722 > (san:fl -100)
1723 [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1724```
1726---
1727### `++lth:fl`
1729Less than
1731Tests if `a` is less than `b`. Returns `~` in the event of `a` or `b` being a
1732NaN (`[%n ~]`).
1734#### Accepts
1736`a` is an `fn`.
1738`b` is an `fn`.
1740#### Produces
1742A `unit` of `flag`.
1744#### Source
1746```
1747 ++ lth
1748 |= [a=fn b=fn] ^- (unit ?)
1749 ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1750 ?: =(a 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
1755 ?: !=(s.a s.b) s.b
1756 ?: s.a (^lth +>.a +>.b) (^lth +>.b +>.a)
1757```
1759#### Examples
1761```
1762 > (lth:fl (sun:fl 116) (sun:fl 4.820))
1763 [~ u=%.y]
1765 > (lth:fl (sun:fl 218.116) (sun:fl 4.820))
1766 [~ u=%.n]
1768 > (lth:fl (sun:fl 218.116) [%n ~])
1770```
1772---
1773### `++lte:fl`
1775Less than or equal
1777Tests whether `a` is less than or equal to `b`. Returns `~` in the event of `a`
1778or `b` being a NaN (`[%n ~]`).
1780#### Accepts
1782`a` is an `fn`.
1784`b` is an `fn`.
1786#### Produces
1788A `unit` of `flag`.
1790#### Source
1792```
1793 ++ lte
1794 |= [a=fn b=fn] ^- (unit ?)
1795 %+ bind (lth b a) |= a=? !a
1796```
1798#### Examples
1800```
1801 > (lte:fl (sun:fl 102) [%f %.y -5 973.655.724])
1802 [~ u=%.y]
1804 > (lte:fl (sun:fl 102) [%f %.y -24 973.655.724])
1805 [~ u=%.n]
1807 > (lte:fl [%f %.y --2 25] (sun:fl 100))
1808 [~ u=%.y]
1810 > (lte:fl [%f %.y --2 25] [%f %.y --3 2])
1811 [~ u=%.n]
1813 > (lte:fl [%f %.y --2 25] [%n ~])
1815```
1817---
1818### `++equ:fl`
1820Equals
1822Tests if `a` is equal to `b`. Returns `~` in the event of `a` or `b` being a NaN
1823(`[%n ~]`).
1825#### Accepts
1827`a` is an `fn`.
1829`b` is an `fn`.
1831#### Produces
1833An `unit` of `flag`.
1835#### Source
1837```
1838 ++ equ
1839 |= [a=fn b=fn] ^- (unit ?)
1840 ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1841 ?: =(a 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)) |
1846 (^equ +>.a +>.b)
1847```
1849#### Examples
1851```
1852 > (equ:fl [%f %.y --2 25] (sun:fl 100))
1853 [~ u=%.y]
1855 > (equ:fl [%f %.y --2 25] (sun:fl 101))
1856 [~ u=%.n]
1857```
1859---
1860### `++gte:fl`
1862Greater or equal than
1864Tests whether `a` is greater than or equal to `b`. Returns `~` in the event of
1865`a` or `b` being a NaN (`[%n ~]`).
1867#### Accepts
1869`a` is an `fn`.
1871`b` is an `fn`.
1873#### Produces
1875An `unit` of `flag`.
1877#### Source
1879```
1880 ++ gte
1881 |= [a=fn b=fn] ^- (unit ?) (lte b a)
1882```
1884#### Examples
1886```
1887 > (gte:fl [%f %.y --2 25] (sun:fl 100))
1888 [~ u=%.y]
1890 > (gth:fl [%f %.y --6 73.989] [%f %.y --5 919.599])
1891 [~ u=%.n]
1893 > (gth:fl [%f %.y --6 73.989] [%n ~])
1895```
1897---
1898### `++gth:fl`
1900Greater than
1902Tests whether `a` is greater than `b`. Returns `~` in the event of `a` or `b`
1903being a NaN (`[%n ~]`).
1905#### Accepts
1907`a` is an `fn`.
1909`b` is an `fn`.
1911#### Produces
1913An `unit` of `flag`.
1915#### Source
1917```
1918 ++ gth
1919 |= [a=fn b=fn] ^- (unit ?) (lth b a)
1920```
1922#### Examples
1924```
1925 > (gth:fl [%f %.y --2 25] (sun:fl 100))
1926 [~ u=%.n]
1928 > (gth:fl [%f %.y --6 73.989] [%f %.y --5 119.599])
1929 [~ u=%.y]
1930```
1932---
1933### `++drg:fl`
1935Float to decimal
1937Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
1938accurate results for rounded floats.
1940#### Accepts
1942`a` is an `fn`.
1944#### Produces
1946A `dn`.
1948#### Source
1950```
1951 ++ drg
1952 |= [a=fn] ^- dn
1953 ?: ?=([$n *] a) [%n ~]
1954 ?: ?=([$i *] a) [%i s.a]
1955 ?~ a.a [%d s.a --0 0]
1956 [%d s.a (^drg +>.a)]
1957```
1959#### Examples
1961```
1962 > (drg:fl [%f | --6 73.989])
1963 [%d s=%.n e=--0 a=4.735.296]
1964```
1966---
1967### `++grd:fl`
1969Decimal to float
1971Converts decimal `a` to `fn`.
1973#### Accepts
1975`a` is a `dn`.
1977#### Produces
1979An `fn`.
1981#### Source
1983```
1984 ++ grd
1985 |= [a=dn] ^- fn
1986 ?: ?=([$n *] a) [%n ~]
1987 ?: ?=([$i *] a) [%i s.a]
1988 => .(r %n)
1989 =+ q=(abs:si e.a)
1990 ?: (syn:si e.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)])
1993```
1995#### Examples
1997```
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]
2003```
2005---
2006### `++toi:fl`
2008Round to signed integer
2010Rounds `a` to the nearest signed integer.
2012#### Accepts
2014`a` is an `fn`.
2016#### Produces
2018A `unit` of @s.
2020#### Source
2022```
2023 ++ toi
2024 |= [a=fn] ^- (unit @s)
2025 =+ b=(toj a)
2026 ?. ?=([$f *] b) ~ :- ~
2027 =+ c=(^^mul (bex (abs:si e.b)) a.b)
2028 (new:si s.b c)
2029```
2031#### Examples
2033```
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]
2036```
2038---
2039### `++toj:fl`
2041Round to integer fn
2043Rounds `a` to the nearest decimal integer.
2045#### Accepts
2047`a` is an `fn`.
2049#### Produces
2051A `unit` of @s.
2053#### Source
2055```
2056 ++ toj
2057 |= [a=fn] ^- fn
2058 ?. ?=([$f *] a) a
2059 ?~ a.a [%f s.a zer]
2060 ?: s.a (^toj +>.a)
2061 =.(r swr (fli (^toj +>.a)))
2062 --
2063```
2065#### Examples
2067```
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]
2079```
2081---
2082### `+ff`
2084IEEE-754 Formatting
2086Container 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`.
2094#### Source
2096```
2097 ++ ff
2098 |_ [[w=@u p=@u b=@s] r=$?($n $u $d $z $a)]
2099```
2101#### Examples
2103```
2104 > =ffcore ~(. ff [8 8 0] %n)
2105 > ffcore
2106 <24.ltg {{{@ud @ud @ud} r/$n} <54.tyv 119.wim 31.ohr 1.jmk $143>}>
2108```
2110---
2111#### Discussion
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
2115meant to power those cores.
2117---
2118### `++sb:ff`
2120Sign bit
2122Produces the sign bit of `++ff`.
2124#### Source
2126```
2127 ++ sb (bex (^add w p))
2128```
2130#### Examples
2132```
2133 > sb:ff
2135```
2137---
2138### `++me:ff`
2140Minimum exponent
2142Produces the minimum possible exponent of `ff`.
2144#### Source
2146```
2147 ++ me (dif:si (dif:si --1 b) (sun:si p))
2148```
2150#### Examples
2152```
2153 > me:ff
2154 --1
2155```
2157---
2158### `++pa:ff`
2160Initialize `fl`
2162Instantiates the core `fl`, giving values to its samples based on the
2163configuration of the `ff` core.
2165#### Source
2167```
2168 ++ pa
2169 %*(. fl p +(p), v me, w (^sub (bex w) 3), d %d, r r)
2170```
2172#### Examples
2174```
2175 > ~(pa ff [11 52 --1.023] %n)
2176 < 23.qzd
2177 28.btz
2178 { {{p/@ v/@s w/@} r/?($n $u $a $d $z) d/$d}
2179 <54.tyv 119.wim 31.ohr 1.jmk $143>
2182```
2184#### Discussion
2186`++pa` exists exclusively for internal use of `++ff`, and `++ff` exists for
2187internal use in other cores.
2189---
2190### `++sea`
2192`@r` to `fn`
2194Converts `a` from `@r` to `fn`.
2196#### Accepts
2198`a` is a `@r`, an IEEE float.
2200#### Produces
2202A `unit` of @s.
2204#### Source
2206```
2207 ++ sea
2208 |= [a=@r] ^- fn
2209 =+ [f=(cut 0 [0 p] a) e=(cut 0 [p w] a)]
2210 =+ s=(sig a)
2211 ?: =(e 0)
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))
2217 [%f s q r]
2218```
2220#### Examples
2222```
2223 > (sea:ff `@r`0x8)
2224 [%f s=%.y e=--0 a=0]
2225```
2227---
2228### `++bit:ff`
2230`fn` to `@r`, rounding
2232Converts `a` from `fn` to `@r` and applies rounding.
2234#### Accepts
2236`a` is an `fn`.
2238#### Produces
2240A `@r`.
2242#### Source
2244```
2245 ++ bit |= [a=fn] (bif (rou:pa a))
2246```
2248#### Examples
2250```
2251 > (bit:ma:rd [%f | -6 202])
2252 0xc009400000000000
2253```
2255---
2256### `++bif:ff`
2258`fn` to `@r`, no rounding
2260Converts `a` from `fn` to `@r`. No rounding is applied.
2262#### Accepts
2264`a` is a `@r`, an IEEE float.
2266#### Produces
2268A `flag`.
2270#### Source
2272```
2273 ++ bif
2274 |= [a=fn] ^- @r
2275 ?: ?=([$i *] a)
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
2280 =+ ma=(met 0 a.a)
2281 ?. =(ma +(p))
2282 ?> =(e.a me)
2283 ?> (^lth ma +(p))
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)
2288```
2290#### Examples
2292```
2293 > (bif:ma:rd *fn)
2294 0x7ff8000000000000
2295```
2297---
2298### `++sig:ff`
2300Get sign
2302Produces the sign of `a`.
2304#### Accepts
2306`a` is a `@r`, an IEEE float.
2308#### Produces
2310A `flag`.
2312#### Source
2314```
2315 ++ sig
2316 |= [a=@r] ^- ?
2317 =(0 (cut 0 [(^add p w) 1] a))
2318```
2320#### Examples
2322```
2323 > (sig:ff `@r`5)
2324 %.n
2325```
2327---
2328### `++exp`
2330Get exponent
2332Produces the exponent of `a`.
2334#### Accepts
2336`a` is a `@r`, an IEEE float.
2338#### Produces
2340A signed integer.
2342#### Source
2344```
2345 ++ exp
2346 |= [a=@r] ^- @s
2347 (dif:si (sun:si (cut 0 [p w] a)) b)
2348```
2350#### Examples
2352```
2353 > (exp:ff `@r`5)
2354 --0
2355```
2357---
2358### `++add`
2360Add
2362Produces the sum of `a` plus `b`.
2364#### Accepts
2366`a` is a `@r`, an IEEE float.
2368`b` is a `@r`, an IEEE float.
2370#### Produces
2372A `@r`, an IEEE float.
2374#### Source
2376```
2377 ++ add
2378 |= [a=@r b=@r]
2379 (bif (add:pa (sea a) (sea b)))
2380```
2382#### Examples
2384```
2385 > (add:ma:rd `@r`5 `@r`11)
2386 0x10
2387```
2389---
2390### `++sub:ff`
2392Sub
2394Produces the sum of `a` plus `b`.
2396#### Accepts
2398`a` is a `@r`, an IEEE float.
2400`b` is a `@r`, an IEEE float.
2402#### Produces
2404A `@r`, an IEEE float.
2406#### Source
2408```
2409 ++ sub
2410 |= [a=@r b=@r]
2411 (bif (sub:pa (sea a) (sea b)))
2412```
2414#### Examples
2416```
2417 > (sub:ma:rd `@r`5 `@r`11)
2418 0x8000000000000006
2419```
2421---
2422### `mul:ff`
2424Multiply
2426Produces the product of `a` multiplied by `b`.
2428#### Accepts
2430`a` is a `@r`, an IEEE float.
2432`b` is a `@r`, an IEEE float.
2434#### Produces
2436A `@r`, an IEEE float.
2438#### Multiply
2440```
2441 ++ mul
2442 |= [a=@r b=@r]
2443 (bif (mul:pa (sea a) (sea b)))
2444```
2446#### Examples
2448```
2449 > (mul:ma:rd `@r`11 `@r`2)
2450 0x0
2451```
2453---
2454### `++div:ff`
2456Divide
2458Produces the quotient of `a` divided by `b`.
2460#### Accepts
2462`a` is a `@r`, an IEEE float.
2464`b` is a `@r`, an IEEE float.
2466#### Produces
2468A `@r`, an IEEE float.
2470#### Source
2472```
2473 ++ div
2474 |= [a=@r b=@r]
2475 (bif (div:pa (sea a) (sea b)))
2476```
2478#### Examples
2480```
2481 > (div:ma:rd `@r`175 `@r`26)
2482 0x401aec4ec4ec4ec4
2483```
2485---
2486### `++fma:ff`
2488Fused multiply-add
2490Produces the sum of `c` plus the product of `a` multiplied by `b`;
2491`(a * b) + c`.
2493#### Accepts
2495`a` is a `@r`, an IEEE float.
2497`b` is a `@r`, an IEEE float.
2499`c` is a `@r`, an IEEE float.
2501#### Produces
2503A `@r`, an IEEE float.
2505#### Source
2507```
2508 ++ fma
2509 |= [a=@r b=@r c=@r]
2510 (bif (fma:pa (sea a) (sea b) (sea c)))
2511```
2513#### Examples
2515```
2516 > (fma:ma:rd `@r`175 `@r`26 `@r`100)
2517 0x64
2518```
2520---
2521### `++sqt:ff`
2523Square root
2525Produces the square root of `a`.
2527#### Accepts
2529`a` is a `@r`, an IEEE float.
2531#### Produces
2533A `@r`, an IEEE float.
2535#### Source
2537```
2538 ++ sqt
2539 |= [a=@r]
2540 (bif (sqt:pa (sea a)))
2541```
2543#### Examples
2545```
2546 > (sqt:ma:rd `@r`175)
2547 0x1e9a751f9447b724
2548```
2550---
2551### `++lth:ff`
2553Less than
2555Tests whether `a` is less than `b`.
2557#### Accepts
2559`a` is a `@r`, an IEEE float.
2561`b` is a `@r`, an IEEE float.
2563#### Produces
2565A `flag`.
2567#### Source
2569```
2570 ++ lth
2571 |= [a=@r b=@r] (fall (lth:pa (sea a) (sea b)) |)
2572```
2574#### Examples
2576```
2577 > (lth:ma:rd `@rd`1 `@rd`2)
2578 %.y
2580 > (lth:ma:rd `@rd`10 `@rd`2)
2581 %.n
2582```
2584---
2585### `++lte:ff`
2587Less than or equal to
2589Tests whether `a` is less than or equal to `b`.
2591#### Accepts
2593`a` is a `@r`, an IEEE float.
2595`b` is a `@r`, an IEEE float.
2597#### Produces
2599A `flag`.
2601#### Source
2603```
2604 ++ lte
2605 |= [a=@r b=@r] (fall (lte:pa (sea a) (sea b)) |)
2606```
2608#### Examples
2610```
2611 > (lte:ma:rd `@rd`10 `@rd`2)
2612 %.n
2614 > (lte:ma:rd `@rd`10 `@rd`10)
2615 %.y
2616```
2618---
2619### `equ:ff`
2621Equals
2623Tests whether `a` is equal to `b`.
2625#### Accepts
2627`a` is a `@r`, an IEEE float.
2629`b` is a `@r`, an IEEE float.
2631#### Produces
2633A `flag`.
2635#### Source
2637```
2638 ++ equ
2639 |= [a=@r b=@r] (fall (equ:pa (sea a) (sea b)) |)
2640```
2642#### Examples
2644```
2645 > (equ:ma:rd `@rd`10 `@rd`2)
2646 %.n
2648 > (equ:ma:rd `@rd`10 `@rd`10)
2649 %.y
2650```
2652---
2653### `++gte:ff`
2655Greater or equal than
2657Tests whether `a` is greater than or equal to `b`.
2659#### Accepts
2661`a` is a `@r`, an IEEE float.
2663`b` is a `@r`, an IEEE float.
2665#### Produces
2667A `flag`.
2669#### Source
2671```
2672 ++ gte
2673 |= [a=@r b=@r] (fall (gte:pa (sea a) (sea b)) |)
2674```
2676#### Examples
2678```
2679 > (gte:ma:rd `@rd`10 `@rd`10)
2680 %.y
2682 > (gte:ma:rd `@rd`10 `@rd`11)
2683 %.n
2684```
2686---
2687### `++gth:ff`
2689Greater than
2691Tests whether `a` is greater than or equal to `b`.
2693#### Accepts
2695`a` is a `@r`, an IEEE float.
2697`b` is a `@r`, an IEEE float.
2699#### Produces
2701A `flag`.
2703#### Source
2705```
2706 ++ gth
2707 |= [a=@r b=@r] (fall (gth:pa (sea a) (sea b)) |)
2708```
2710#### Examples
2712```
2713 > (gth:ma:rd `@rd`10 `@rd`10)
2714 %.n
2716 > (gth:ma:rd `@rd`10 `@rd`9)
2717 %.y
2718```
2720---
2721### `++sun:ff`
2723Unsigned integer to `@r`
2725Converts `a` from an unsigned integer (`@u`) to `@r`.
2727#### Accepts
2729`a` is `@u`, unsigned integer.
2731#### Produces
2733A `@r`, an IEEE float.
2735#### Source
2737```
2738 ++ sun
2739 |= [a=@u] (bit [%f & --0 a])
2740```
2742#### Examples
2744```
2745 > (sun:ma:rd 658.149.282)
2746 0x41c39d47d1000000
2747```
2749---
2750### `++san:ff`
2752Signed integer to `@r`
2754Converts `a` from a signed integer to `@r`.
2756#### Accepts
2758`a` is `@s`, an unsigned integer
2760#### Produces
2762A `@r`, an IEEE float.
2764#### Source
2766```
2767 ++ san
2768 |= [a=@s] (bit [%f (syn:si a) --0 (abs:si a)])
2769```
2771#### Examples
2773```
2774 > (san:ma:rd --10)
2775 0x4024000000000000
2776```
2778---
2779### `++toi:ff`
2781Round to integer
2783Rounds `a` to the nearest signed integer.
2785#### Accepts
2787`a` is a `@r`, an IEEE float.
2789#### Produces
2791A `flag` of `@s`.
2793#### Source
2795```
2796 ++ toi
2797 |= [a=@r] (toi:pa (sea a))
2798```
2800#### Examples
2802```
2803 > (toi:ma:rd `@r`0x4af)
2804 [~ u=--0]
2805```
2807---
2808### `++drg:ff`
2810`@r` to decimal float
2812Converts `a` from `@r` to `dn` using the Dragon4 algorithm.
2814#### Accepts
2816`a` is a `@r`, an IEEE float.
2818#### Produces
2820A `dn`.
2822#### Source
2824```
2825 ++ drg
2826 |= [a=@r] (drg:pa (sea a))
2827```
2829#### Examples
2831```
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]
2837```
2839---
2840### `++grd:ff`
2842Decimal float to `@r`
2844Converts `a` from `dn` to `@r`.
2846#### Accepts
2848`a` is a `dn`.
2850#### Produces
2852A `@r`, an IEEE float.
2854#### Source
2856```
2857 ++ grd
2858 |= [a=dn] (bif (grd:pa a))
2859 --
2860```
2862#### Examples
2864```
2865 > (grd:ma:rd [%d s=%.y e=--0 a=658.149.282])
2866 0x41c39d47d1000000
2867```
2869---
2870### `rlyd`
2872Prep `@rd` for print
2874Converts `a` from a double-precision binary float to decimal64.
2876#### Accepts
2878`a` is a `@rd`, a double-precision float.
2880#### Produces
2882A `dn`.
2884#### Source
2886```
2887 ++ rlyd |= a=@rd ^- dn (drg:rd a)
2888```
2890#### Examples
2892```
2893 > (rlyd .~2.4703e-320)
2894 [%d s=%.y e=-324 a=24.703]
2895```
2897---
2898### `++rlys`
2900Prep @rs for print
2902Converts `a` from a single-precision binary float to decimal32.
2904#### Accepts
2906`a` is a `@rs`, a single-precision float.
2908#### Produces
2910A `dn`.
2912#### Source
2914```
2915 ++ rlys |= a=@rs ^- dn (drg:rs a)
2916```
2918#### Examples
2920```
2921 > (rlys .1.681557e-39)
2922 [%d s=%.y e=-45 a=1.681.557]
2923```
2925---
2926### `++rlyh`
2928Prep `@rh` for print
2930Converts `a` from a half-precision binary float to decimal16.
2932#### Accepts
2934`a` is a `@rh`, a half-precision float.
2936#### Produces
2938A `dn`.
2940#### Source
2942```
2943 ++ rlyh |= a=@rh ^- dn (drg:rh a)
2944```
2946#### Examples
2948```
2949 > (rlyh .~~3e1)
2950 [%d s=%.y e=--1 a=3]
2951```
2953---
2954### `++rlyq`
2956Prep `@rq` for print
2958Converts `a` from a quad-precision binary float to decimal128.
2960#### Accepts
2962`a` is a `@rq`, a quad-precision float.
2964#### Produces
2966A `dn`.
2968#### Source
2970```
2971 ++ rlyq |= a=@rq ^- dn (drg:rq a)
2972```
2974#### Examples
2976```
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]
2979```
2981---
2982### `++ryld`
2984Finish parsing `@rd`
2986Converts `a` from a decimal float to a double-precision binary float.
2988#### Accepts
2990`a` is a `dn`.
2992#### Produces
2994A a `@rd`, a double-precision float.
2996#### Source
2998```
2999 ++ ryld |= a=dn ^- @rd (grd:rd a)
3000```
3002#### Examples
3004```
3005 > (ryld [%d s=%.y e=-324 a=24.703])
3006 .~2.4703e-320
3007```
3009---
3010### `++ryls`
3012Finish parsing `@rs`
3014Converts `a` from a decimal float to a single-precision binary float.
3016#### Accepts
3018`a` is a `dn`.
3020#### Produces
3022A a `@rs`, a single-precision float.
3024#### Source
3026```
3027 ++ ryls |= a=dn ^- @rs (grd:rs a)
3028```
3030#### Examples
3032```
3033 > (ryls [%d s=%.y e=-324 a=24.703])
3034 .0
3036 > (ryls [%d s=%.y e=-32 a=24.703])
3037 .2.4703e-28
3038```
3040---
3041### `++rylh`
3043Finish parsing `@rh`
3045Converts `a` from a decimal float to a half-precision binary float.
3047#### Accepts
3049`a` is a `dn`.
3051#### Produces
3053A a `@rh`, a half-precision float.
3055#### Source
3057```
3058 ++ rylh |= a=dn ^- @rh (grd:rh a)
3059```
3061#### Examples
3063```
3064 > (rylh [%d s=%.y e=--1 a=703])
3065 .~~7.032e3
3067 > (rylh [%d s=%.y e=--3 a=56])
3068 .~~5.6e4
3070 > (rylh [%d s=%.y e=--4 a=56])
3071 .~~inf
3072```
3074---
3075### `++rylq`
3077Finish parsing `@rq`
3079Converts `a` from a decimal float to a quad-precision binary float.
3081#### Accepts
3083`a` is a `dn`.
3085#### Produces
3087A a `@rq`, a quad-precision float.
3089#### Source
3091```
3092 ++ rylq |= a=dn ^- @rq (grd:rq a)
3093```
3095#### Examples
3097```
3098 > (rylq [%d s=%.y e=-324 a=24.703])
3099 .~~~2.4703e-320
3100```
3102---
3103### `++rd`
3105Double-precision fp
3107A container core for operations related to double-precision binary floats.
3109`++rd` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3110down (`$d`), and round to zero (`$z`).
3112#### Source
3114```
3115 ++ rd
3116 ^?
3117 ~% %rd +> ~
3118 |_ r=$?($n $u $d $z)
3119```
3121---
3122### `++ma:rd`
3124Initialize `ff`
3126Instantiates the core `ff`, giving values to its samples based on the
3127configuration of the `rd` core.
3129#### Source
3131```
3132 ++ ma
3133 %*(. ff w 11, p 52, b --1.023, r r)
3134```
3136#### Examples
3138```
3139 > ~(ma rd %n)
3140 < 24.ltg
3141 {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3143```
3145---
3146### `sea:rd`
3148`@rd` to `fn`
3150Converts `a` from a double-precision binary float to `fn`.
3152```
3153 ++ sea :: @rd to fn
3154 |= [a=@rd] (sea:ma a)
3155```
3157#### Examples
3159```
3160 > (sea:rd .~4.94066e-319)
3161 [%f s=%.y e=-1.074 a=100.000]
3162```
3164---
3165### `bit:rd`
3167`fn` to `@rd`
3169Converts `a` from `fn` to a double-precision binary float.
3171#### Accepts
3173`a` is an `fn`.
3175#### Produces
3177A `@rd`, a double-precision float.
3179#### Source
3181```
3182 ++ bit
3183 |= [a=fn] ^- @rd (bit:ma a)
3184```
3186#### Examples
3188```
3189 > (bit:rd [%f s=%.y e=-1.074 a=100.000])
3190 .~4.94066e-319
3191```
3193---
3194### `add:rd`
3196Add
3198Produces the sum of `a` plus `b`.
3200#### Accepts
3202`a` is a `@rd`, a double-precision float.
3204`b` is a `@rd`, a double-precision float.
3206#### Produces
3208A `@rd`.
3210#### Source
3212```
3213 ++ add ~/ %add
3214 |= [a=@rd b=@rd] ^- @rd
3215 ~_ leaf+"rd-fail"
3216 (add:ma a b)
3217```
3219#### Examples
3221```
3222 > (add:rd .~3.94066e12 .~9.2846e11)
3223 .~4.86912e12
3224```
3226---
3227### `sub:rd`
3229Subtract
3231Produces the difference of `a` minus `b`.
3233#### Accepts
3235`a` is a `@rd`, a double-precision float.
3237`b` is a `@rd`, a double-precision float.
3239#### Produces
3241A `@rd`.
3243#### Source
3245```
3246 ++ sub ~/ %sub
3247 |= [a=@rd b=@rd] ^- @rd
3248 ~_ leaf+"rd-fail"
3249 (sub:ma a b)
3250```
3252#### Examples
3254```
3255 > (sub:rd .~7.94069e2 .~1.2846e3)
3256 .~-4.9053099999999995e2
3257```
3259---
3260### `sub:rd`
3262Multiply
3264Produces the product of `a` times `b`.
3266#### Accepts
3268`a` is a `@rd`, a double-precision float.
3270`b` is a `@rd`, a double-precision float.
3272#### Produces
3274A `@rd`.
3276#### Source
3278```
3279 ++ mul ~/ %mul
3280 |= [a=@rd b=@rd] ^- @rd
3281 ~_ leaf+"rd-fail"
3282 (mul:ma a b)
3283```
3285#### Examples
3287```
3288 > (mul:rd .~7.94069e2 .~1.2246e3)
3289 .~9.724168973999998e5
3290```
3292---
3293### `div:rd`
3295Divide
3297Produces the quotient of `a` divided by `b`.
3299#### Accepts
3301`a` is a `@rd`, a double-precision float.
3303`b` is a `@rd`.
3305#### Produces
3307A `@rd`.
3309#### Source
3311```
3312 ++ div ~/ %div
3313 |= [a=@rd b=@rd] ^- @rd
3314 ~_ leaf+"rd-fail"
3315 (div:ma a b)
3316```
3318#### Examples
3320```
3321 > (div:rd .~7.94099e2 .~1.2246e3)
3322 .~6.484558223093255e-1
3323```
3325---
3326### `++fma:rd`
3328Fused multiply-add
3330Produces the sum of `c` plus the product of `a` multiplied by `b`;
3331`(a * b) + c`.
3333#### Accepts
3335`a` is a `@rd`, an IEEE float.
3337`b` is a `@rd`.
3339`c` is a `@rd`.
3341#### Produces
3343A `@rd`.
3345#### Source
3348#### Source
3350```
3351 ++ fma ~/ %fma
3352 |= [a=@rd b=@rd c=@rd] ^- @rd
3353 ~_ leaf+"rd-fail"
3354 (fma:ma a b c)
3355```
3357#### Examples
3359```
3360 > (fma:rd .~7.94099e2 .~1.2246e3 .~3.94066e3)
3361 .~9.763942954e5
3362```
3364---
3365### `+sqt:fr`
3367Square root
3369Produces the square root of `a`.
3371#### Accepts
3373`a` is a `@rd`, a double-precision float.
3375#### Produces
3377A `@rd`.
3379#### Source
3381```
3382 ++ sqt ~/ %sqt
3383 |= [a=@rd] ^- @rd ~_ leaf+"rd-fail"
3384 (sqt:ma a)
3385```
3387#### Examples
3389```
3390 > (sqt:rd .~3.94066e3)
3391 .~6.2774676422901614e1
3392```
3394---
3395### `lth:rd`
3397Less than
3399Test whether `a` is less than `b`.
3401#### Accepts
3403`a` is a `@rd`, a double-precision float.
3405`b` is a `@rd`, a double-precision float.
3407#### Produces
3409A `@rd`.
3411#### Source
3413```
3414 ++ lth ~/ %lth
3415 |= [a=@rd b=@rd]
3416 ~_ leaf+"rd-fail"
3417 (lth:ma a b)
3418```
3420#### Examples
3422```
3423 > (lth:rd .~7.94099e2 .~1.2246e3)
3424 %.y
3426 > (lth:rd .~7.94099e2 .~1.2246e2)
3427 %.n
3429 > (lth:rd .~1.2246e2 .~1.2246e2)
3430 %.n
3431```
3433---
3434### `++lte:rd`
3436Less than or equal
3438Test whether `a` is less than or equal to `b`.
3440#### Accepts
3442`a` is a `@rd`, a double-precision float.
3444`b` is a `@rd`, a double-precision float.
3446#### Produces
3448A `@rd`.
3450#### Source
3452```
3453 ++ lte ~/ %lte :: less-equals
3454 |= [a=@rd b=@rd]
3455 ~_ leaf+"rd-fail"
3456 (lte:ma a b)
3457```
3459#### Examples
3461```
3462 > (lte:rd .~7.94099e2 .~1.2246e3)
3463 %.y
3465 > (lte:rd .~7.94099e2 .~1.2246e2)
3466 %.n
3468 > (lte:rd .~1.2246e2 .~1.2246e2)
3469 %.y
3470```
3472---
3473### `equ:rd`
3475Equals
3477Test whether `a` is equal to `b`.
3479#### Accepts
3481`a` is a `@rd`, a double-precision float.
3483`b` is a `@rd`, a double-precision float.
3485#### Produces
3487A `@rd`.
3489#### Source
3491```
3492 ++ equ ~/ %equ
3493 |= [a=@rd b=@rd]
3494 ~_ leaf+"rd-fail"
3495 (equ:ma a b)
3496```
3498#### Examples
3500```
3501 > (equ:rd .~7.94099e2 .~1.2246e3)
3502 %.n
3504 > (equ:rd .~7.94099e2 .~1.2246e2)
3505 %.n
3507 > (equ:rd .~1.2246e2 .~1.2246e2)
3508 %.y
3509```
3511---
3512### `++gte:rd`
3514Greater than or equal
3516Test whether `a` is greater than or equal to `b`.
3518#### Accepts
3520`a` is a `@rd`, a double-precision float.
3522`b` is a `@rd`, a double-precision float.
3524#### Produces
3526A `@rd`.
3528#### Source
3530```
3531 ++ gte ~/ %gte
3532 |= [a=@rd b=@rd]
3533 ~_ leaf+"rd-fail"
3534 (gte:ma a b)
3535```
3537#### Examples
3539```
3540 > (gte:rd .~7.94099e2 .~1.2246e3)
3541 %.n
3543 > (gte:rd .~7.94099e2 .~1.2246e2)
3544 %.y
3546 > (gte:rd .~1.2246e2 .~1.2246e2)
3547 %.y
3548```
3550---
3551### `++gth:rd`
3553Greater than
3555Test whether `a` is greater `b`.
3557#### Accepts
3559`a` is a `@rd`, a double-precision float.
3561`b` is a `@rd`, a double-precision float.
3563#### Produces
3565A `@rd`.
3567#### Source
3569```
3570 ++ gth ~/ %gth
3571 |= [a=@rd b=@rd]
3572 ~_ leaf+"rd-fail"
3573 (gth:ma a b)
3574```
3576#### Examples
3578```
3579 > (gte:rd .~7.94099e2 .~1.2246e3)
3580 %.n
3582 > (gte:rd .~7.94099e2 .~1.2246e2)
3583 %.y
3585 > (gte:rd .~1.2246e2 .~1.2246e2)
3586 %.y
3587```
3589---
3590### `++sun:rd`
3592Unsigned integer to `@rd`
3594Converts an unsigned integer `a` to `@rd`.
3596#### Accepts
3598`a` is a `@u`, an unsigned integer.
3600#### Produces
3602A `@rd`.
3604#### Source
3606```
3607 ++ sun |= [a=@u] ^- @rd (sun:ma a)
3608```
3610#### Examples
3612```
3613 > (sun:rd 511)
3614 .~5.11e2
3615```
3617---
3618### `++san:rd`
3620Unsigned integer to `@rd`
3622Converts a signed integer `a` to `@rd`.
3624#### Accepts
3626`a` is a `@s`, a signed integer.
3628#### Produces
3630A `@rd`.
3632#### Source
3634```
3635 ++ san |= [a=@s] ^- @rd (san:ma a)
3636```
3638#### Examples
3640```
3641 > (san:rd -511)
3642 .~-5.11e2
3643```
3645---
3646### `++sig:rd`
3648Get sign
3650Produces the sign of `a`.
3652#### Accepts
3654`a` is a `@rd`
3656#### Produces
3658A `flag`.
3660#### Source
3662```
3663 ++ sig |= [a=@rd] ^- ? (sig:ma a)
3664```
3666#### Examples
3668```
3669 > (sig:rd .~1.2246e3)
3670 %.y
3671```
3673---
3674### `exp:rd`
3676Get exponent
3678Produces the exponent of `a`.
3680#### Accepts
3682`a` is a `@rd`
3684#### Produces
3686A `@s`.
3688#### Source
3690```
3691 ++ exp |= [a=@rd] ^- @s (exp:ma a) :: get exponent
3692```
3694#### Examples
3696```
3697 > (exp:rd .~1.2246e3)
3698 --10
3699```
3701---
3702### `++toi:rd`
3704Round to integer
3706Rounds `a` to the nearest integer.
3708#### Accepts
3710`a` is a `@rd`
3712#### Produces
3714A `unit` of `@s`.
3716#### Source
3718```
3719 ++ toi |= [a=@rd] ^- (unit @s) (toi:ma a)
3720```
3722#### Examples
3724```
3725 > (toi:rd .~1.2246e3)
3726 [~ u=--1.224]
3727```
3729---
3730### `++drg:rd`
3732`@rd` to decimal float
3734Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
3735accurate results for rounded floats.
3737#### Accepts
3739`a` is a `@rd`
3741#### Produces
3743A `dn`.
3745#### Source
3747```
3748 ++ drg |= [a=@rd] ^- dn (drg:ma a)
3749```
3751#### Examples
3753```
3754 > (drg:rd .~1.2246e3)
3755 [%d s=%.y e=-1 a=12.246]
3756```
3758---
3759### `++grd:rd`
3761Decimal float to `@rd`
3763Converts `a` from decimal float to `@rd`.
3765#### Accepts
3767`a` is a `@dn`
3769#### Produces
3771A `@rd`.
3773#### Source
3775```
3776 ++ grd |= [a=dn] ^- @rd (grd:ma a) :: decimal float to @rd
3777 --
3778```
3780#### Examples
3782```
3783 > (grd:rd [%d s=%.y e=-1 a=12.246])
3784 .~1.2246e3
3785```
3787---
3788### `++rs`
3790Single-precision fp
3792A container core for operations related to single-precision binary floats.
3794`++rs` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3795down (`$d`), and round to zero (`$z`).
3797#### Source
3799```
3800 ++ rs
3801 ~% %rs +> ~
3802 ^?
3803 |_ r=$?($n $u $d $z)
3804```
3806---
3807### `ma:rs`
3809Initialize `ff`
3811Instantiates the core `ff`, giving values to its samples based on the
3812configuration of the `rs` core.
3814#### Source
3816```
3817 ++ ma
3818 %*(. ff w 8, p 23, b --127, r r)
3819```
3821#### Examples
3823```
3824 > ~(ma rs %n)
3825 < 24.ltg
3826 {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3828```
3830---
3831### `sea:rs`
3833`@rs` to `fn`
3835Converts `a` from `@rs` to `fn`.
3837#### Accepts
3839`a` is a `@rs`, an single-precision float.
3841#### Produces
3843An `fn`.
3845#### Source
3847```
3848 ++ sea
3849 |= [a=@rs] (sea:ma a)
3850```
3852#### Examples
3854```
3855 > (sea:rs .1.4e-43)
3856 [%f s=%.y e=-149 a=100]
3857```
3859---
3860### `bit:rs`
3862`fn` to `@rs`
3864Converts `a` from `fn` to `@rs`.
3866#### Accepts
3868`a` is an `fn`.
3870#### Produces
3872A `@rs`, a single-precision float.
3874#### Source
3876```
3877 ++ bit
3878 |= [a=fn] ^- @rs (bit:ma a)
3879```
3881#### Examples
3883```
3884 > (bit:rs [%f & -2 1.000])
3885 .2.5e2
3886```
3888---
3889### `++add:rs`
3891Add
3893Produces the sum of `a` plus `b`.
3895#### Accepts
3897`a` is a `@rs`, a single-precision float.
3899`b` is a `@rs`.
3901#### Produces
3903A `@rs`.
3905#### Source
3907```
3908 ++ add ~/ %add
3909 |= [a=@rs b=@rs] ^- @rs
3910 ~_ leaf+"rs-fail"
3911 (add:ma a b)
3912```
3914#### Examples
3916```
3917 > (add:rs .2.5e1 .2.5e2)
3918 .2.75e2
3919```
3921---
3922### `++sub:rs`
3924Subtract
3926Subtracts `a` from `b`.
3928#### Source
3930```
3931 ++ sub ~/ %sub
3932 |= [a=@rs b=@rs] ^- @rs
3933 ~_ leaf+"rs-fail"
3934 (sub:ma a b)
3935```
3937#### Examples
3939```
3940 > (sub:rs .2.5e1 .2.5e2)
3941 .-2.25e2
3942```
3944---
3945### `++mul:rs`
3947Multiply
3949Produces the product of `a` multiplied by `b`.
3951#### Accepts
3953`a` is a `@rs`, a single-precision float.
3955`b` is a `@rs`.
3957#### Produces
3959A `@rs`.
3961#### Source
3963```
3964 ++ mul ~/ %mul
3965 |= [a=@rs b=@rs] ^- @rs
3966 ~_ leaf+"rs-fail"
3967 (mul:ma a b)
3968```
3970#### Examples
3972```
3973 > (mul:rs .2.5e1 .2.5e2)
3974 .6.25e3
3975```
3977---
3978### `++div:rs`
3980Divide
3982Produces the quotient of `a` divided by `b`.
3984#### Accepts
3986`a` is a `@rs`, a single-precision float.
3988`b` is a `@rs`.
3990#### Produces
3992A `@rs`.
3994#### Source
3996```
3997 ++ div ~/ %div
3998 |= [a=@rs b=@rs] ^- @rs
3999 ~_ leaf+"rs-fail"
4000 (div:ma a b)
4001```
4003#### Examples
4005```
4006 > (div:rs .4.5e1 .2.2e2)
4007 .2.0454545e-1
4008```
4010---
4011### `++fma:rs`
4013Fused multiply-add
4015Produces the sum of `c` plus the product of `a` multiplied by `b`;
4016`(a * b) + c`.
4018#### Accepts
4020`a` is a `@rs`, a single-precision float.
4022`b` is a `@rs`.
4024`c` is a `@rs`.
4026#### Produces
4028A `@rs`.
4030#### Source
4032```
4033 ++ fma ~/ %fma
4034 |= [a=@rs b=@rs c=@rs] ^- @rs
4035 ~_ leaf+"rs-fail"
4036 (fma:ma a b c)
4037```
4039#### Examples
4041```
4042 > (fma:rs .2.5e1 .2.5e2 .8.2e1)
4043 .6.332e3
4044```
4046---
4047### `++sqt:rs`
4049Square root
4051Produces the square root of `a`.
4053#### Accepts
4055`a` is a `@rs`, a single-precision float.
4057#### Produces
4059A `@rs`.
4061#### Source
4063```
4064 ++ sqt ~/ %sqt
4065 |= [a=@rs] ^- @rs
4066 ~_ leaf+"rs-fail"
4067 (sqt:ma a)
4068```
4070#### Examples
4072```
4073 > (sqt:rs .2.5e2)
4074 .1.5811388e1
4075```
4077---
4078### `lth:rs`
4080Less than
4082Test whether `a` is less than `b`.
4084#### Accepts
4086`a` is a `@rs`, a single-precision float.
4088`b` is a `@rs`.
4090#### Produces
4092A `@rs`.
4094#### Source
4096```
4097 ++ lth ~/ %lth
4098 |= [a=@rs b=@rs]
4099 ~_ leaf+"rs-fail"
4100 (lth:ma a b)
4101```
4103#### Examples
4105```
4106 > (lth:rs .9.9e1 .1.1e2)
4107 %.y
4109 > (lth:rs .9.9e1 .9.9e1)
4110 %.n
4111```
4113---
4114### `++lte:rs`
4116Less than or equal
4118Test whether `a` is less than or equal to `b`.
4120#### Accepts
4122`a` is a `@rs`, a single-precision float.
4124`b` is a `@rs`.
4126#### Produces
4128A `@rs`.
4130#### Source
4132```
4133 ++ lte ~/ %lte
4134 |= [a=@rs b=@rs]
4135 ~_ leaf+"rs-fail"
4136 (lte:ma a b)
4137```
4139#### Examples
4141```
4142 > (lte:rs .9.9e1 .1.1e2)
4143 %.y
4145 > (lte:rs .9.9e1 .9.9e1)
4146 %.y
4147```
4149---
4150### `equ:rs`
4152Equals
4154Test whether `a` is equal to `b`.
4156#### Accepts
4158`a` is a `@rs`, a single-precision float.
4160`b` is a `@rs`.
4162#### Produces
4164A `@rs`.
4166#### Source
4168```
4169 ++ equ ~/ %equ
4170 |= [a=@rs b=@rs]
4171 ~_ leaf+"rs-fail"
4172 (equ:ma a b)
4173```
4175#### Examples
4177```
4178 > (equ:rs .9.9e1 .1.1e2)
4179 %.n
4181 > (equ:rs .9.9e1 .9.9e1)
4182 %.y
4183```
4185---
4186### `++gte:rs`
4188Greater than or equal
4190Test whether `a` is greater than or equal to `b`.
4192#### Accepts
4194`a` is a `@rs`, a single-precision float.
4196`b` is a `@rs`.
4198#### Produces
4200A `@rs`.
4202#### Source
4204```
4205 ++ gte ~/ %gte
4206 |= [a=@rs b=@rs]
4207 ~_ leaf+"rs-fail"
4208 (gte:ma a b)
4209```
4211#### Examples
4213```
4214 > (gte:rs .9.9e1 .9.9e1)
4215 %.y
4217 > (gte:rs .9.9e1 .9.2e2)
4218 %.n
4219```
4221---
4222### `++gth:rs`
4224Greater than
4226Test whether `a` is greater than `b`.
4228#### Accepts
4230`a` is a `@rs`, a single-precision float.
4232`b` is a `@rs`.
4234#### Produces
4236A `@rs`.
4238#### Source
4240```
4241 ++ gth ~/ %gth
4242 |= [a=@rs b=@rs]
4243 ~_ leaf+"rs-fail"
4244 (gth:ma a b)
4245```
4247#### Examples
4249```
4250 > (gth:rs .9.9e1 .9.2e2)
4251 %.n
4253 > (gth:rs .9.9e1 .9.9e1)
4254 %.n
4256 > (gth:rs .9.9e1 .1.9e1)
4257 %.y
4258```
4260---
4261### `++sun:rs`
4263Unsigned integer to `@rs`
4265Converts `a` from an unsigned integer to `@rs`.
4267#### Accepts
4269`a` is an unsigned integer.
4271#### Produces
4273A `@rs`.
4275#### Source
4277```
4278 ++ sun |= [a=@u] ^- @rs (sun:ma a)
4279```
4281#### Examples
4283```
4284 > (sun:rs 343)
4285 .3.43e2
4286```
4288---
4289### `++san:rs`
4291Signed integer to `@rs`'
4293Converts `a` from an unsigned integer to `@rs`.
4295#### Accepts
4297`a` is a signed integer.
4299#### Produces
4301A `@rs`.
4303#### Source
4305```
4306 ++ san |= [a=@s] ^- @rs (san:ma a)
4307```
4309#### Examples
4311```
4312 > (san:rs -343)
4313 .-3.43e2'
4314```
4316### `++sig:rs`
4318Get sign
4320Produces the sign of `a`.
4322#### Accepts
4324`a` is a `@rs`.
4326#### Produces
4328A `flag`.
4330#### Source
4332```
4333 ++ sig |= [a=@rs] ^- ? (sig:ma a)
4334```
4336#### Examples
4338```
4339 > (sig:rs .3.43e2)
4340 %.y
4342 > (sig:rs .-3.43e2)
4343 %.n
4344```
4346---
4347### `exp:rs`
4349Get exponent
4351Produces the exponent of `a`.
4353#### Accepts
4355`a` is a `@rs`.
4357#### Produces
4359A signed integer.
4361#### Source
4363```
4364 ++ exp |= [a=@rs] ^- @s (exp:ma a)
4365```
4367#### Examples
4369```
4370 > (exp:rs .-3.43e2)
4371 --8
4372```
4374---
4375### `++toi:rs`
4377Round to integer
4379Rounds `a` to the nearest integer.
4381#### Accepts
4383`a` is a `@rs`.
4385#### Produces
4387A `unit` of `@s`.
4389#### Source
4391```
4392 ++ toi |= [a=@rs] ^- (unit @s) (toi:ma a)
4393```
4395#### Examples
4397```
4398 > (toi:rs .-3.43e2)
4399 [~ u=-343]
4400```
4402---
4403### `++drg:rs`
4405`@rs` to decimal float
4407Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
4408accurate results for rounded floats.
4410#### Accepts
4412`a` is a `@rs`
4414#### Produces
4416A `dn`.
4418#### Source
4420```
4421 ++ drg |= [a=@rs] ^- dn (drg:ma a)
4422```
4424#### Examples
4426```
4427 > (drg:rs .-3.43e2)
4428 [%d s=%.n e=--0 a=343]
4429```
4431---
4432### `++grd:rs`
4434Decimal float to `@rs`
4436Converts `a` from `dn` to `@rs`.
4438#### Accepts
4440`a` is a `dn`.
4442#### Produces
4444A `@rs`.
4446#### Source
4448```
4449 ++ grd |= [a=dn] ^- @rs (grd:ma a)
4450 --
4451```
4453#### Examples
4455```
4456 > (grd:rs [%d s=%.n e=--0 a=343])
4457 .-3.43e2
4458```
4460---
4461### `++rq`
4463Quadruple-precision fp
4465A container core for operations related to quadruple-precision binary floats.
4467`++rq` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
4468down (`$d`), and round to zero (`$z`).
4470#### Source
4472```
4473 ++ rq
4474 ~% %rq +> ~
4475 ^?
4476 |_ r=$?($n $u $d $z)
4477```
4479### `++ma:rq`
4481Initialize `ff`
4483Instantiates the core `ff`, giving values to its samples based on the
4484configuration of the `rq` core.
4486#### Source
4488```
4489 ++ ma
4490 %*(. ff w 15, p 112, b --16.383, r r)
4491```
4493---
4494### `++sea:rq`
4496`@rq` to `fn`
4498Converts `a` from `@rq` to `fn`.
4500#### Accepts
4502`a` is a `@rq`, a quad-precision float.
4504#### Produces
4506An `fn`.
4508#### Source
4510```
4511 ++ sea
4512 |= [a=@rq] (sea:ma a)
4513```
4515#### Examples
4517```
4518 > (sea:rq .~~~1.05102e5)
4519 [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272]
4520```
4522---
4523### `++bit:rq`
4525`fn` to `@rq`
4527Converts `a` from `fn` to `@rq`.
4529#### Accepts
4531`a` is an `fn`.
4533#### Produces
4535A `@rq`, a quad-precision float.
4537#### Source
4539```
4540 ++ bit
4541 |= [a=n] ^- @rq (bit:ma a)
4542```
4544#### Examples
4546```
4547 > (bit:rq [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272])
4548 .~~~1.05102e5
4549```
4551---
4552### `++add:rq`
4554Add
4556Produces the sum of `a` plus `b`.
4558#### Accepts
4560`a` is a `@rq`, a quad-precision float.
4562`b` is a `@rq`.
4564#### Produces
4566A `@rq`.
4568#### Source
4570```
4571 ++ add ~/ %add
4572 |= [a=@rq b=@rq] ^- @rq
4573 ~_ leaf+"rq-fail"
4574 (add:ma a b)
4575```
4577#### Examples
4579```
4580 > (add:rq .~~~-1.821e5 .~~~1.05102e5)
4581 .~~~-7.6998e4
4582```
4584---
4585### `++sub:rq`
4587Subtract
4589Produces the difference of `a` minus `b`.
4591#### Accepts
4593`a` is a `@rq`, a quad-precision float.
4595`b` is a `@rq`.
4597#### Produces
4599A `@rq`.
4601#### Source
4603```
4604 ++ sub ~/ %sub
4605 |= [a=@rq b=@rq] ^- @rq
4606 ~_ leaf+"rq-fail"
4607 (sub:ma a b)
4608```
4610#### Examples
4612```
4613 > (sub:rq .~~~1.821e5 .~~~1.05102e5)
4614 .~~~7.6998e4
4616 > (sub:rq .~~~1.821e5 .~~~-1.05102e5)
4617 .~~~2.87202e5
4618```
4620---
4621### `++mul:rq`
4623Multiply
4625Produces the product of `a` times `b`.
4627#### Accepts
4629`a` is a `@rq`, a quad-precision float.
4631`b` is a `@rq`.
4633#### Produces
4635A `@rq`.
4637#### Source
4639```
4640 ++ mul ~/ %mul
4641 |= [a=@rq b=@rq] ^- @rq
4642 ~_ leaf+"rq-fail"
4643 (mul:ma a b)
4644```
4646#### Examples
4648```
4649 > (mul:rq .~~~1.821e5 .~~~-1.05102e5)
4650 .~~~-1.91390742e10
4651```
4653---
4654### `div:rq`
4656Divide
4658Produces the product of `a` divided by `b`.
4660#### Accepts
4662`a` is a `@rq`, a quad-precision float.
4664`b` is a `@rq`.
4666#### Produces
4668A `@rq`.
4670#### Source
4672```
4673 ++ div ~/ %div
4674 |= [a=@rq b=@rq] ^- @rq
4675 ~_ leaf+"rq-fail"
4676 (div:ma a b)
4677```
4679#### examples
4681```
4682 > (div:rq .~~~1.821e5 .~~~1.05102e3)
4683 .~~~1.732602614602957127361991208540275e2
4684```
4686---
4687### `fma:rq`
4689Fused multiply-add
4691Produces the sum of `c` plus the product of `a` multiplied by `b`;
4692`(a * b) + c`.
4694#### Accepts
4696`a` is a `@rq`, a quad-precision float.
4698`b` is a `@rq`.
4700`c` is a `@rq`.
4702#### Produces
4704A `@rq`.
4706#### Source
4708```
4709 ++ fma ~/ %fma
4710 |= [a=@rq b=@rq c=@rq] ^- @rq
4711 ~_ leaf+"rq-fail"
4712 (fma:ma a b c)
4713```
4715#### Examples
4717```
4718 > (fma:rq .~~~1.821e5 .~~~-1.05102e2 .~~~6.2044e7)
4719 .~~~4.29049258e7
4720```
4722---
4723#### Source
4725Square root
4727Produces the square root of `a`.
4729#### Accepts
4731`a` is a `@rq`, a quad-precision float.
4733#### Produces
4735A `@rq`.
4737#### Source
4739```
4740 ++ sqt ~/ %sqt
4741 |= [a=@rq] ^- @rq
4742 ~_ leaf+"rq-fail"
4743 (sqt:ma a)
4744```
4746#### Source
4748```
4749 > (sqt:rq .~~~6.2044e7)
4750 .~~~7.876801381271461258959876570289002e3
4751```
4753---
4754### `++lth:rq`
4756Less than
4758Tests whether `a` is less than `b`.
4760#### Accepts
4762`a` is a `@rq`, a quad-precision float.
4764`b` is a `@rq`.
4766#### Produces
4768A `@rq`.
4770#### Source
4772```
4773 ++ lth ~/ %lth
4774 |= [a=@rq b=@rq]
4775 ~_ leaf+"rq-fail"
4776 (lth:ma a b)
4777```
4780#### Examples
4782```
4783 > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4784 %.n
4786 > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4787 %.y
4788```
4790---
4791### `lte:rq`
4793Less than or equal
4795Tests whether `a` is less than or equal to `b`.
4797#### Accepts
4799`a` is a `@rq`, a quad-precision float.
4801`b` is a `@rq`.
4803#### Produces
4805A `@rq`.
4807#### Source
4809```
4810 ++ lte ~/ %lte
4811 |= [a=@rq b=@rq]
4812 ~_ leaf+"rq-fail"
4813 (lte:ma a b)
4814```
4816#### Examples
4818```
4819 > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4820 %.n
4822 > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4823 %.y
4825 > (lte:rq .~~~1.2044e7 .~~~1.2044e7)
4826 %.y
4827```
4829---
4830### `++equ:rq`
4832Equals
4834Tests whether `a` is equal to `b`.
4836#### Accepts
4838`a` is a `@rq`, a quad-precision float.
4840`b` is a `@rq`.
4842#### Produces
4844A `@rq`.
4846#### Source
4848```
4849 ++ equ ~/ %equ
4850 |= [a=@rq b=@rq]
4851 ~_ leaf+"rq-fail"
4852 (equ:ma a b)
4853```
4855#### Examples
4857```
4858 > (equ:rq .~~~1.2044e7 .~~~1.2044e7)
4859 %.y
4861 > (equ:rq .~~~2.2044e7 .~~~1.2044e7)
4862 %.n
4863```
4865---
4866### `++gte:rq`
4868Greater than or equal
4870Tests whether `a` is greater than or equal to `b`.
4872#### Accepts
4874`a` is a `@rq`, a quad-precision float.
4876`b` is a `@rq`.
4878#### Produces
4880A `@rq`.
4882#### Source
4884```
4885 ++ gte ~/ %gte
4886 |= [a=@rq b=@rq]
4887 ~_ leaf+"rq-fail"
4888 (gte:ma a b)
4889```
4891#### Examples
4893```
4894 > (gte:rq .~~~1.2044e7 .~~~1.2044e7)
4895 %.y
4897 > (gte:rq .~~~2.2044e7 .~~~1.2044e7)
4898 %.y
4900 > (gte:rq .~~~1.2044e7 .~~~2.2044e7)
4901 %.n
4902```
4904---
4905### `++gth:rq`
4907Tests whether `a` is greater than `b`.
4909#### Accepts
4911`a` is a `@rq`, a quad-precision float.
4913`b` is a `@rq`.
4915#### Produces
4917A `@rq`.
4919#### Source
4921```
4922 ++ gth ~/ %gth
4923 |= [a=@rq b=@rq]
4924 ~_ leaf+"rq-fail"
4925 (gth:ma a b)
4926```
4928#### Examples
4930```
4931 > (gth:rq .~~~1.2044e7 .~~~1.2044e7)
4932 %.n
4934 > (gth:rq .~~~2.2044e7 .~~~1.2044e7)
4935 %.y
4937 > (gth:rq .~~~1.2044e7 .~~~2.2044e7)
4938 %.n
4939```
4941---
4942### `++sun:rq`
4944Unsigned integer to `@rq`
4946Converts `@` from an unsigned integer to `@rq`.
4948#### Accepts
4950`a` is a `@u`, an unsigned integer.
4952#### Produces
4954A `@rq`, a quad-precision float.
4956#### Source
4958```
4959 ++ sun |= [a=@u] ^- @rq (sun:ma a)
4960```
4962#### Examples
4964```
4965 > (sun:rq 205)
4966 .~~~2.05e2
4967```
4969---
4970### `++san:rq`
4972Signed integer to `rq`
4974Converts `@` from a signed integer to `@rq`.
4976#### Accepts
4978`a` is a `@s`, a signed integer.
4980#### Produces
4982A `@rq`, a quad-precision float.
4984#### Source
4986```
4987 ++ san |= [a=@s] ^- @rq (san:ma a)
4988```
4990#### Examples
4992```
4993 > (san:rq -205)
4994 .~~~-2.05e2
4995```
4997---
4998### `++sig:rq`
5000Get sign
5002Produces the sign of `a`.
5004#### Accepts
5006`a` is a `@rq`, a quad-precision float.
5008#### Produces
5010A `flag`.
5012#### Source
5014```
5015 ++ sig |= [a=@rq] ^- ? (sig:ma a)
5016```
5018#### Examples
5020```
5021 > (sig:rq .~~~-2.05e2)
5022 %.n
5023```
5025---
5026### `++exp:rq`
5028Get exponent
5030Gets the exponent of `a`.
5032#### Accepts
5034`a` is a `@rq`, a quad-precision float.
5036#### Produces
5038A `@s`, a signed integer.
5040#### Source
5042```
5043 ++ exp |= [a=@rq] ^- @s (exp:ma a)
5044```
5046#### Examples
5048```
5049 > (exp:rq .~~~-2.05e2)
5050 --7
5051```
5053---
5054### `toi:rq`
5056Round to integer
5058Rounds `a` to the nearest integer.
5060#### Accepts
5062`a` is a `@rq`, a quad-precision float.
5064#### Produces
5066A `unit` of `@s`.
5068#### Source
5070```
5071 ++ toi |= [a=@rq] ^- (unit @s) (toi:ma a)
5072```
5074#### Examples
5076```
5077 > (toi:rq .~~~-2.085e2)
5078 [~ u=-208]
5080 > (toi:rq .~~~-2.08e2)
5081 [~ u=-208]
5082```
5084---
5085### `++drg:rq`
5087`@rq` to decimal float
5089Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5090accurate results for rounded floats.
5092#### Accepts
5094`a` is a `@rq`, a quad-precision float.
5096#### Produces
5098A `dn`.
5100#### Source
5102```
5103 ++ drg |= [a=@rq] ^- dn (drg:ma a) :: @rq to decimal float
5104```
5106#### Examples
5108```
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]
5114```
5116---
5117### `++grd:rq`
5119Decimal float to `@rq`
5121Converts `a` from `dn` to `@rq`.
5123#### Accepts
5125`a` is `dn`.
5127`a` is a `@rq`.
5129#### Produces
5131A `@rq`, a quad-precision float.
5133#### Source
5135```
5136 ++ grd |= [a=dn] ^- @rq (grd:ma a)
5137 --
5138```
5140#### Examples
5142```
5143 > (grd:rq [%d s=%.n e=--0 a=343])
5144 .~~~-3.43e2
5145```
5147---
5148### `++rh`
5150Half-precision fp
5152A container core for operations related to half-precision binary floats.
5154`++rh` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
5155down (`$d`), and round to zero (`$z`).
5157#### Source
5159```
5160 ++ rh
5161 ~% %rh +> ~
5162 ^?
5163 |_ r=$?($n $u $d $z)
5164```
5166---
5167### `++ma:rh`
5169Initialize `ff`
5171Instantiates the core `ff`, giving values to its samples based on the
5172configuration of the `rh` core.
5174#### Source
5176```
5177 ++ ma
5178 %*(. ff w 5, p 10, b --15, r r)
5179```
5181---
5182### `++sea:rh`
5184`@rh` to `fn`
5186Converts `a` from `@rh` to `fn`.
5188#### Accepts
5190`a` is a `@rh`, a half-precision float.
5192#### Produces
5194An `fn`.
5196#### Source
5198```
5199 ++ sea
5200 |= [a=@rh] (sea:ma a)
5201```
5203#### Examples
5205```
5206 > (sea:rh .~~1.22e-5)
5207 [%f s=%.y e=-24 a=205]
5208```
5210---
5211### `++bit:rh`
5213`fn` to `@rh`
5215Converts `a` from `fn` to `@rh`.
5217#### Accepts
5219`a` is an `fn`.
5221#### Produces
5223A `@rh`, a half-precision float.
5225#### Source
5227```
5228 ++ bit
5229 |= [a=fn] ^- @rh (bit:ma a)
5230```
5232#### Examples
5234```
5235 > (bit:rh [%f s=%.y e=-24 a=205])
5236 .~~1.22e-5
5237```
5239---
5240### `++add:rh`
5242Produces the sum of `a` plus `b`.
5244#### Accepts
5246`a` is a `@rh`, a half-precision float.
5248`b` is a `@rh`.
5250#### Produces
5252A `@rh`.
5254#### Source
5256```
5257 ++ add ~/ %add
5258 |= [a=@rh b=@rh] ^- @rh
5259 ~_ leaf+"rh-fail"
5260 (add:ma a b)
5261```
5263#### Examples
5265```
5266 > (add:rh .~~1.82e2 .~~1.02e2)
5267 .~~2.84e2
5268```
5270---
5271### `++sub:rh`
5273Subtract
5275Produces the difference of `a` minus `b`.
5277#### Accepts
5279`a` is a `@rh`, a half-precision float.
5281`b` is a `@rh`.
5283#### Produces
5285A `@rh`.
5287#### Source
5289```
5290 ++ sub ~/ %sub
5291 |= [a=@rh b=@rh] ^- @rh
5292 ~_ leaf+"rh-fail"
5293 (sub:ma a b)
5294```
5296#### Examples
5298```
5299 > (sub:rh .~~1.821e2 .~~1.051e2)
5300 .~~7.7e1
5302 > (sub:rh .~~1.821e2 .~~6.051e2)
5303 .~~-4.228e2
5304```
5306---
5307### `++mul:rh`
5309Multiply
5311Produces the product of `a` times `b`.
5313#### Accepts
5315`a` is a `@rh`, a quad-precision float.
5317`b` is a `@rh`.
5319#### Produces
5321A `@rh`.
5323#### Source
5325```
5326 ++ mul ~/ %mul
5327 |= [a=@rh b=@rh] ^- @rh
5328 ~_ leaf+"rh-fail"
5329 (mul:ma a b)
5330```
5332#### Examples
5334```
5335 > (mul:rh .~~1.821e1 .~~-1.05102e2)
5336 .~~-1.913e3
5337```
5339---
5340### `div:rh`
5342Divide
5344Produces the product of `a` divided by `b`.
5346#### Accepts
5348`a` is a `@rh`, a half-precision float.
5350`b` is a `@rh`.
5352#### Produces
5354A `@rh`.
5356#### Source
5358```
5359 ++ div ~/ %div
5360 |= [a=@rh b=@rh] ^- @rh
5361 ~_ leaf+"rh-fail"
5362 (div:ma a b)
5363```
5365#### examples
5367```
5368 > (div:rh .~~1.821e3 .~~1.05102e2)
5369 .~~1.731e1
5370```
5372---
5373### `fma:rh`
5375Fused multiply-add
5377Produces the sum of `c` plus the product of `a` multiplied by `b`;
5378`(a * b) + c`.
5380#### Accepts
5382`a` is a `@rh`, a half-precision float.
5384`b` is a `@rh`.
5386`c` is a `@rh`.
5388#### Produces
5390A `@rh`.
5392#### Source
5394```
5395 ++ fma ~/ %fma
5396 |= [a=@rh b=@rh c=@rh] ^- @rh
5397 ~_ leaf+"rh-fail"
5398 (fma:ma a b c)
5399```
5401#### Examples
5403```
5404 > (fma:rh .~~1.821e4 .~~-1.05102e2 .~~6.2044e3)
5405 .~~-6.55e4
5406```
5408---
5409#### Source
5411Square root
5413Produces the square root of `a`.
5415#### Accepts
5417`a` is a `@rh`, a half-precision float.
5419#### Produces
5421A `@rh`.
5423#### Source
5425```
5426 ++ sqt ~/ %sqt
5427 |= [a=@rh] ^- @rh
5428 ~_ leaf+"rh-fail"
5429 (sqt:ma a)
5430```
5432#### Source
5434```
5435 > (sqt:rh .~~6.24e4)
5436 .~~2.498e2
5437```
5439---
5440### `++lth:rh`
5442Less than
5444Tests whether `a` is less than `b`.
5446#### Accepts
5448`a` is a `@rh`, a half-precision float.
5450`b` is a `@rh`.
5452#### Produces
5454A `@rh`.
5456#### Source
5458```
5459 ++ lth ~/ %lth
5460 |= [a=@rh b=@rh]
5461 ~_ leaf+"rh-fail"
5462 (lth:ma a b)
5463```
5465#### Examples
5467```
5468 > (lth:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5469 %.n
5471 > (lth:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5472 %.y
5473```
5475---
5476### `lte:rh`
5478Less than or equal
5480Tests whether `a` is less than or equal to `b`.
5482#### Accepts
5484`a` is a `@rh`, a half-precision float.
5486`b` is a `@rh`.
5488#### Produces
5490A `@rh`.
5492#### Source
5494```
5495 ++ lte ~/ %lte
5496 |= [a=@rh b=@rh]
5497 ~_ leaf+"rh-fail"
5498 (lte:ma a b)
5499```
5501#### Examples
5503```
5504 > (lth:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5505 %.n
5507 > (lth:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5508 %.y
5510 > (lte:rh .~~1.2e3 .~~1.2e3)
5511 %.y
5512```
5514---
5515### `++equ:rh`
5517Equals
5519Tests whether `a` is equal to `b`.
5521#### Accepts
5523`a` is a `@rh`, a half-precision float.
5525`b` is a `@rh`.
5527#### Produces
5529A `@rh`.
5531#### Source
5533```
5534 ++ equ ~/ %equ
5535 |= [a=@rh b=@rh]
5536 ~_ leaf+"rh-fail"
5537 (equ:ma a b)
5538```
5540#### Examples
5542```
5543 > (equ:rh .~~1.24e4 .~~1.24e4)
5544 %.y
5546 > (equ:rh .~~2.24e4 .~~1.24e4)
5547 %.n
5548```
5550---
5551### `++gte:rh`
5553Greater than or equal
5555Tests whether `a` is greater than or equal to `b`.
5557#### Accepts
5559`a` is a `@rh`, a half-precision float.
5561`b` is a `@rh`.
5563#### Produces
5565A `@rh`.
5567#### Source
5569```
5570 ++ gte ~/ %gte
5571 |= [a=@rh b=@rh]
5572 ~_ leaf+"rh-fail"
5573 (gte:ma a b)
5574```
5576#### Examples
5578```
5579 > (gte:rh .~~1.24e4 .~~1.24e4)
5580 %.y
5582 > (gte:rh .~~2.24e4 .~~1.24e4)
5583 %.y
5585 > (gte:rh .~~1.24e4 .~~2.24e4)
5586 %.n
5587```
5589---
5590### `++gth:rh`
5592Tests whether `a` is greater than `b`.
5594#### Accepts
5596`a` is a `@rh`, a half-precision float.
5598`b` is a `@rh`.
5600#### Produces
5602A `@rh`.
5604#### Source
5606```
5607 ++ gth ~/ %gth
5608 |= [a=@rh b=@rh]
5609 ~_ leaf+"rh-fail"
5610 (gth:ma a b)
5611```
5613#### Examples
5615```
5616 > (gth:rh .~~1.24e4 .~~1.244e4)
5617 %.n
5619 > (gth:rh .~~2.24e4 .~~1.24e4)
5620 %.y
5622 > (gth:rh .~~1.24e4 .~~2.24e4)
5623 %.n
5624```
5626---
5627### `++sun:rh`
5629Unsigned integer to `@rh`
5631Converts `@` from an unsigned integer to `@rh`.
5633#### Accepts
5635`a` is a `@u`, an unsigned integer.
5637#### Produces
5639A `@rh`, a half-precision float.
5641#### Source
5643```
5644 ++ sun |= [a=@u] ^- @rh (sun:ma a)
5645```
5647#### Examples
5649```
5650 > (sun:rh 205)
5651 .~~2.05e2
5652```
5654---
5655### `++san:rh`
5657Signed integer to `@rh`
5659Converts `@` from a signed integer to `@rh`.
5661#### Accepts
5663`a` is a `@s`, a signed integer.
5665#### Produces
5667A `@rh`, a half-precision float.
5669#### Source
5671```
5672 ++ san |= [a=@s] ^- @rh (san:ma a)
5673```
5675#### Examples
5677```
5678 > (san:rh -205)
5679 .~~-2.05e2
5680```
5682---
5683### `++sig:rh`
5685Get sign
5687Produces the sign of `a`.
5689#### Accepts
5691`a` is a `@rh`, a half-precision float.
5693#### Produces
5695A `flag`.
5697#### Source
5699```
5700 ++ sig |= [a=@rh] ^- ? (sig:ma a)
5701```
5703#### Examples
5705```
5706 > (sig:rh .~~-2.05e2)
5707 %.n
5708```
5710---
5711### `++exp:rh`
5713Get exponent
5715Gets the exponent of `a`.
5717#### Accepts
5719`a` is a `@rh`, a half-precision float.
5721#### Produces
5723A `@s`, a signed integer.
5725#### Source
5727```
5728 ++ exp |= [a=@rh] ^- @s (exp:ma a)
5729```
5731#### Examples
5733```
5734 > (exp:rh .~~-2.05e2)
5735 --7
5736```
5738---
5739### `toi:rh`
5741Round to integer
5743Rounds `a` to the nearest integer.
5745#### Accepts
5747`a` is a `@rh`, a half-precision float.
5749#### Produces
5751A `unit` of `@s`.
5753#### Source
5755```
5756 ++ toi |= [a=@rh] ^- (unit @s) (toi:ma a)
5757```
5759#### Examples
5761```
5762 > (toi:rh .~~-2.085e2)
5763 [~ u=-208]
5765 > (toi:rh .~~-2.08e2)
5766 [~ u=-208]
5767```
5769---
5770### `++drg:rh`
5772`@rh` to decimal float
5774Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5775accurate results for rounded floats.
5777#### Accepts
5779`a` is a `@rh`, a half-precision float.
5781#### Produces
5783A `dn`.
5785#### Source
5787```
5788 ++ drg |= [a=@rh] ^- dn (drg:ma a)
5789```
5791#### Examples
5793```
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]
5799```
5801---
5802### `++grd:rh`
5804Decimal float to `@rh`
5806Converts `a` from `dn` to `@rh`.
5808#### Accepts
5810`a` is `dn`.
5812`a` is a `@rh`.
5814#### Produces
5816A `@rh`, a a half-precision float.
5818#### Source
5820```
5821 ++ grd |= [a=dn] ^- @rh (grd:ma a)
5822 --
5823```
5825#### Examples
5827```
5828 > (grd:rh [%d s=%.n e=--0 a=343])
5829 .~~-3.43e2
5830```
5832---