on b93c19b help sign in
5888 lines 83 kB history raw
1+++
2title = "3b: Floating Point"
3weight = 22
4template = "doc.html"
5+++
6### `++fn`
8Float
10A mold for the floating-point arithmetic using the base of two, the formula is
11`(-1)^s * a * 2^e`.
13Produces either a float (`$f`), an infinity of other sign (`$i`),
14or not-a-number (`$n`). `s` refers to sign, the `flag`s `&` or `|`; `e` to
15exponent, a signed decimal; and `a` to the significand, an unsigned integer.
17#### Source
19```
20 ++ fn
21 $% [$f s=? e=@s a=@u]
22 [$i s=?]
23 [$n ~]
24 ==
25```
27### Examples
29```
30 > *fn
31 [%n ~]
33 > (add:fl [%f & --33 2] [%f | --23 2])
34 [%f s=%.y e=-79 a=10.374.452.512.267.829.421.849.019.032.797.184]
36 > (add:fl [%i &] [%i &])
37 [%i s=%.y]
39 > (add:fl [%n ~] [%i |])
40 [%n ~]
42 > (sun:fl 961.193.554.848.514.048.973.893.027.381.506.219.443)
43 [%f s=%.y e=--17 a=7.333.324.850.834.000.007.430.214.137.126.970]
44```
47---
48### `++dn`
50Decimal float
52A mold for the floating-point arithmetic using the base of 10; the formula is
53`(-1)^s * a *10^e`.
55Valid values are a float (`$d`), an infinity (`$i`), or a not-a-number (`$n`).
56`s` refers to sign, the `flag`s `&` or `|`; `e` to exponent, a signed decimal;
57and `a` to the significand, an unsigned integer.
59```
60 ++ dn
61 $% [$d s=? e=@s a=@u]
62 [$i s=?]
63 [$n ~]
64 ==
65```
67#### Examples
69```
70 > `dn`[%d & --0 17.163.091.968]
71 [%d s=%.y e=--0 a=17.163.091.968]
73 > `dn`[%i s=%.y]
74 [%i s=%.y]
76 > `dn`[%n ~]
77 [%n ~]
78```
80---
81### `++rn`
83Parsed decimal float
85A mold for the floating-point arithmetic using the base of 10; the formula is
86`(-1)^s * a *10^e`.
88Produces either a parsed float (`$d`), infinity of either sign (`$i`), or
89not-a-number (`$n`).
91#### Source
93```
94 $% [$d a=? b=[c=@ [d=@ e=@] f=? i=@]]
95 [$i a=?]
96 [$n ~]
97 ==
98```
100#### Examples
102```
103 > `rn`[%d | [2 [3 4] | 17.163]]
104 [%d a=%.n b=[c=2 [d=3 e=4] f=%.n i=17.163]]
105```
107---
108### `++fl`
110Arbitrary-precision floating-point
112Container arm for floating-point arithmetic functions.
114- Precision (`p`): number of bits in the significand; must be at least 2.
115 Default is 113.
116- Minimum exponent (`v`): minimum value of e. Default is -16.494.
117- Width (`w`): Max value of `e` minus min value of `e`. 0 is for fixed-point.
118 Default is 32.765.
119- Rounding mode (`r`): Possible modes are nearest (`$n`), up (`$u`),
120 down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%n`.
121- Behavior (`d`): return denormals (`$d`), flush denormals to zero (`$z`),
122 infinite exponent range (`$i`). Default value is `%d`.
124#### Source
126```
127 ++ fl
128 =+ ^- [[p=@u v=@s w=@u] r=$?($n $u $d $z $a) d=$?($d $f $i)]
129 [[113 -16.494 32.765] %n %d]
130 =>
131 ~% %cofl +> ~
132 |%
133```
135---
136### `++rou:fl`
138Round
140Rounds `a` to a the nearest float that can be represented with a 113-bit
141significand. There is no term to sign the significand, meaning that a positive
142sign will always be produced.
144#### Accepts
146`a` is a cell of a signed integer and an unsigned integer.
148#### Produces
150An `fn`.
152#### Source
154```
155 ++ rou
156 |= [a=[e=@s a=@u]] ^- fn (rau a &)
157```
159#### Examples
161```
162 > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
163 > (^rou:fl [--12 a])
164 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
166 > (^rou:fl [--12 (add a 1)])
167 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
169 > (^rou:fl [--12 (add a 300)])
170 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
172 > (^rou:fl [--12 (add a 1.000)])
173 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
174```
176---
177### `++rau:fl`
179Various roundings
181Rounds `a` based on what the state of of `r` in the core contained in `fl`. `t`
182is a sticky bit that represents a value less than ULP(a) = 2^(e.a) when passed
183to `lug:fl`.
185#### Accepts
187`a` is a cell of a signed integer and an unsigned integer.
189`t` is a `flag`.
191#### Produces
193An `fn`.
195#### Source
197```
198 ++ rau
199 |= [a=[e=@s a=@u] t=?] ^- fn
200 ?- r
201 $z (lug %fl a t) $d (lug %fl a t)
202 $a (lug %ce a t) $u (lug %ce a t)
203 $n (lug %ne a t)
204 ==
205```
207#### Examples
209```
210 > (rau:fl [-18 342.602.577] &)
211 [%f s=%.y e=-102 a=6.626.897.619.228.945.634.459.505.846.648.832]
212```
215#### Discussion
217See `lug:fl` for possible rounding operations.
219---
220### `++add:fl`
222Add
224Produces the sum of `a` and `b`. `e` is used to choose between an exact result
225(any-sized significand) or a rounded result (113-bit significand).
227There is no term to sign the significands, so a positive sign will always be
228produced.
230#### Accepts
232`a` is an `fn`.
234`b` is an `fn`
236`e` is a `flag`.
238#### Produces
240An `fn`.
242#### Source
244```
245 ++ add
246 |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
247 =+ q=(dif:si e.a e.b)
248 |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp
249 ?: e
250 [%f & e.b (^add (lsh 0 (abs:si q) a.a) a.b)]
251 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
252 =+ ^= w %+ dif:si e.a %- sun:si :: expanded exp of a
253 ?: (gth prc ma) (^sub prc ma) 0
254 =+ ^= x %+ sum:si e.b (sun:si mb) :: highest exp for b
255 ?: =((cmp:si w x) --1) :: don't need to add
256 ?- r
257 $z (lug %fl a &) $d (lug %fl a &)
258 $a (lug %lg a &) $u (lug %lg a &)
259 $n (lug %na a &)
260 ==
261 (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)])
262```
264#### Examples
266```
267 > (^add:fl [--33 2.718] [--23 11] %.y)
268 [%f s=%.y e=--23 a=2.783.243]
270 > (^add:fl [--33 2.718] [--23 11] %.n)
271 [%f s=%.y e=-68 a=6.890.975.897.521.519.304.902.126.405.156.864]
272```
274---
275### `++sub:fl`
277Subtract
279Produces the difference of `a` minus `b.` `e` is used to choose between an exact
280result (any-sized significand) or a rounded result (113-bit significand).
282#### Accepts
284`a` is a cell of a signed integer and an unsigned integer.
286`b` is a cell of a signed integer and an unsigned integer.
288`e` is a `flag`.
290#### Produces
292An `fn`.
294#### Source
296```
297 ++ sub
298 |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
299 =+ q=(dif:si e.a e.b)
300 |- ?. (syn:si q)
301 (fli $(b a, a b, q +(q), r swr))
302 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
303 =+ ^= w %+ dif:si e.a %- sun:si
304 ?: (gth prc ma) (^sub prc ma) 0
305 =+ ^= x %+ sum:si e.b (sun:si +(mb))
306 ?: &(!e =((cmp:si w x) --1))
307 ?- r
308 $z (lug %sm a &) $d (lug %sm a &)
309 $a (lug %ce a &) $u (lug %ce a &)
310 $n (lug %nt a &)
311 ==
312 =+ j=(lsh 0 (abs:si q) a.a)
313 |- ?. (gte j a.b)
314 (fli $(a.b j, j a.b, r swr))
315 =+ i=(^sub j a.b)
316 ?~ i [%f & zer]
317 ?: e [%f & e.b i] (rou [e.b i])
318```
320#### Examples
322```
323 > (^sub:fl [--33 2.718] [--23 11] %.y)
324 [%f s=%.y e=--23 a=2.783.221]
326 > (^sub:fl [--33 2.718] [--63 11] %.y)
327 [%f s=%.n e=--33 a=11.811.157.346]
328```
330---
331### `++mul:fl`
333Multiply
335Produces the product of `a` multiplied by `b`. There is no term to sign the
336significands, so a positive sign will always be produced.
338#### Accepts
340`a` is a cell of a signed integer and an unsigned integer.
342`b` is a cell of a signed integer and an unsigned integer.
344#### Produces
346An `fn`.
348#### Source
350```
351 ++ mul
352 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
353 (rou (sum:si e.a e.b) (^mul a.a a.b))
354```
356#### Examples
358```
359 > (^mul:fl [--3 2.718] [--23 11])
360 [%f s=%.y e=-72 a=9.475.054.411.405.900.661.487.108.108.582.912]
361```
363---
364### `++div:fl`
366Divide
368Produces the quotient of `a` divided by `b`. There is no term to sign the
369significands, so a positive sign will always be produced.
371#### Accepts
373`a` is a cell of a signed integer and an unsigned integer.
375`b` is a cell of a signed integer and an unsigned integer.
377#### Produces
379An `fn`.
381#### Source
383```
384 ++ div
385 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
386 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
387 =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc))))
388 =. a ?: (syn:si v) a
389 a(e (sum:si v e.a), a (lsh 0 (abs:si v) a.a))
390 =+ [j=(dif:si e.a e.b) q=(dvr a.a a.b)]
391 (rau [j p.q] =(q.q 0))
392```
394#### Examples
396```
397 > (^div:fl [--13 2.718] [--23 11])
398 [%f s=%.y e=-115 a=10.023.198.055.040.952.765.870.659.817.343.907]
399```
401---
402### `++sqt:fl`
404Square root
406Produces the square root of `a`.
408#### Accepts
410`a` is a cell of a signed integer and an unsigned integer.
412#### Produces
414An `fn`.
416#### Source
418```
419 ++ sqt
420 |= [a=[e=@s a=@u]] ^- fn
421 =. a
422 =+ [w=(met 0 a.a) x=(^mul +(prc) 2)]
423 =+ ?:((^lth w x) (^sub x w) 0)
424 =+ ?: =((dis - 1) (dis (abs:si e.a) 1)) -
425 (^add - 1)
426 a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
427 =+ [y=(^sqt a.a) z=(fra:si e.a --2)]
428 (rau [z p.y] =(q.y 0))
429```
431#### Examples
433```
434 > (^sqt:fl [-18 342.602.577])
435 [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
436```
438---
439### `++lth:fl`
441Less than
443Tests if `a` is less than `b`.
445#### Accepts
447`a` is a cell of a signed integer and an unsigned integer.
449`b` is a cell of a signed integer and an unsigned integer.
451#### Produces
453An `flag`.
455#### Source
457```
458 ++ lth
459 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
460 ?: =(e.a e.b) (^lth a.a a.b)
461 =+ c=(cmp:si (ibl a) (ibl b))
462 ?: =(c -1) & ?: =(c --1) |
463 ?: =((cmp:si e.a e.b) -1)
464 (^lth (rsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
465 (^lth (lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
466```
468#### Examples
470```
471 > (^lth:fl [-4 684] [--0 35])
472 %.n
474 > (^lth:fl [-4 684] [--0 90])
475 %.y
476```
478---
479### `++equ:fl`
481Equals
483Tests if `a` is equal to `b`.
485#### Accepts
487`a` is a cell of a signed integer and an unsigned integer.
489`b` is a cell of a signed integer and an unsigned integer.
491#### Produces
493A `flag`.
495#### Source
497```
498 ++ equ
499 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
500 ?. =((ibl a) (ibl b)) |
501 ?: =((cmp:si e.a e.b) -1)
502 =((lsh 0 (abs:si (dif:si e.a e.b)) a.b) a.a)
503 =((lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
504```
506#### Examples
508```
509 > (^equ:fl [-4 480] [-0 50])
510 %.n
512 > (^equ:fl [-4 480] [-0 30])
513 %.y
514```
516---
517### `++ibl:fl`
519Integer binary logarithm
521Produces the lowest power to which the number 2 must be raised to obtain `a` or
522greater.
524#### Accepts
526`a` is a cell of a signed integer and an unsigned integer.
528#### Produces
530A signed integer.
532#### Source
534```
535 ++ ibl
536 |= [a=[e=@s a=@u]] ^- @s
537 (sum:si (sun:si (dec (met 0 a.a))) e.a)
538```
540#### Examples
542```
543 > (ibl:fl [-18 342.602.577])
544 --10
545```
547---
548### `++uni:fl`
550Change representation to odd
552Produces another representation of the floating point `a` where the significand
553is odd. Every floating-point number has a unique representation of this kind. If
554the significand of `a` is already odd, nothing changes.
556#### Accepts
558`a` is a cell of a signed integer and an unsigned integer.
560#### Produces
562A cell of a signed integer and an unsigned integer.
564#### Source
566```
567 ++ uni
568 |= [a=[e=@s a=@u]]
569 |- ?: =((end 0 1 a.a) 1) a
570 $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1))
571```
573#### Examples
575```
576 > (uni:fl [-8 342.602.578])
577 [e=-7 a=171.301.289]
579 > (uni:fl [-8 342.602.577])
580 [e=-8 a=342.602.577]
581```
583---
584### `++xpd:fl`
586Expand
588Produces the fully precise form of `a`, or the denormalized form of `a`.
590#### Accepts
592`a` is a cell of a signed integer and an unsigned integer.
594#### Produces
596A cell of a signed integer and an unsigned integer.
598#### Sources
600```
601 ++ xpd
602 |= [a=[e=@s a=@u]]
603 =+ ma=(met 0 a.a)
604 ?: (gte ma prc) a
605 =+ ?: =(den %i) (^sub prc ma)
606 =+ ^= q
607 =+ w=(dif:si e.a emn)
608 ?: (syn:si w) (abs:si w) 0
609 (min q (^sub prc ma))
610 a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
611```
613#### Examples
615```
616 > (xpd:fl [--3 12])
617 [e=-106 a=7.788.445.287.802.241.442.795.744.493.830.144]
619 > (xpd:fl [-8 342.602.577])
620 [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
622 > (xpd:fl [-92 6.626.897.619.228.945.634.459.505.846.648.832])
623 [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
624```
626---
627### `++lug:fl`
629Central rounding mechanism
631Performs various rounding operations on `a`. An operation is chosen based on the
632value selected for `t`. `s` is a sticky bit that represents a value less than
633ULP(a) = 2^(e.a)
635Possible rounding operations:
636- Floor (`$fl`)
637- Ceiling (`$ce`)
638- Smaller (`$sm`)
639- Larger (`$lg`)
640- Nearest (`$ne`) -- Rounds ties away from 0 if the number is even, rounds
641 toward 0 if the number is odd.
643#### Accepts
645`t` is one of the following: `$fl`, `$ce`, `$sm`, `$lg`, `$ne`, `$na`, or `$nt`.
647`a` is a cell of a signed integer and an unsigned integer.
649`s` is a flag.
651#### Produces
653An `fn`.
655#### Source
657```
658 ::
659 :: central rounding mechanism
660 :: can perform: floor, ceiling, smaller, larger,
661 :: nearest (round ties to: even, away from 0, toward 0)
662 :: s is sticky bit: represents a value less than ulp(a) = 2^(e.a)
663 ::
664 ++ lug
665 ~/ %lug
666 |= [t=$?($fl $ce $sm $lg $ne $na $nt) a=[e=@s a=@u] s=?] ^- fn
667 ?< =(a.a 0)
668 =-
669 ?. =(den %f) - :: flush denormals
670 ?. ?=([$f *] -) -
671 ?: =((met 0 ->+>) prc) - [%f & zer]
672 ::
673 =+ m=(met 0 a.a)
674 ?> |(s (gth m prc)) :: require precision
675 =+ ^= q %+ max
676 ?: (gth m prc) (^sub m prc) 0 :: reduce precision
677 %- abs:si ?: =(den %i) --0 :: enforce min. exp
678 ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0
679 =^ b a :- (end 0 q a.a)
680 a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a))
681 ::
682 ?~ a.a
683 ?< =(den %i)
684 ?- t
685 $fl [%f & zer]
686 $sm [%f & zer]
687 $ce [%f & spd]
688 $lg [%f & spd]
689 $ne ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
690 [%f & ?:((^lth b (bex (dec q))) zer spd)]
691 $nt ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
692 [%f & ?:((^lth b (bex (dec q))) zer spd)]
693 $na [%f & ?:((^lth b (bex (dec q))) zer spd)]
694 ==
695 ::
696 =. a (xpd a)
697 ::
698 =. a
699 ?- t
700 $fl a
701 $lg a(a +(a.a))
702 $sm ?. &(=(b 0) s) a
703 ?: &(=(e.a emn) !=(den %i)) a(a (dec a.a))
704 =+ y=(dec (^mul a.a 2))
705 ?. (lte (met 0 y) prc) a(a (dec a.a))
706 [(dif:si e.a --1) y]
707 $ce ?: &(=(b 0) s) a a(a +(a.a))
708 $ne ?~ b a
709 =+ y=(bex (dec q))
710 ?: &(=(b y) s) :: round halfs to even
711 ?~ (dis a.a 1) a a(a +(a.a))
712 ?: (^lth b y) a a(a +(a.a))
713 $na ?~ b a
714 =+ y=(bex (dec q))
715 ?: (^lth b y) a a(a +(a.a))
716 $nt ?~ b a
717 =+ y=(bex (dec q))
718 ?: =(b y) ?: s a a(a +(a.a))
719 ?: (^lth b y) a a(a +(a.a))
720 ==
721 ::
722 =. a ?. =((met 0 a.a) +(prc)) a
723 a(a (rsh 0 1 a.a), e (sum:si e.a --1))
724 ?~ a.a [%f & zer]
725 ::
726 ?: =(den %i) [%f & a]
727 ?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp
728 ::
729```
731---
732### `++drg:fl`
734Get printable decimal
736Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
737accurate results for rounded floats.
739#### Accepts
741`a` is a cell of a signed integer and an unsigned integer.
743#### Produces
745A cell of a signed integer and an unsigned integer.
747#### Source
749```
750 ++ drg
751 ~/ %drg
752 |= [a=[e=@s a=@u]] ^- [@s @u]
753 ?< =(a.a 0)
754 =. a (xpd a)
755 =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a)
756 =+ s=(lsh 0 ?.((syn:si e.a) (abs:si e.a) 0) 1)
757 =+ mn=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) 1)
758 =+ mp=mn
759 => ?.
760 ?& =(a.a (bex (dec prc))) :: if next smallest
761 |(!=(e.a emn) =(den %i)) :: float is half ULP,
762 == :: tighten lower bound
763 .
764 %= .
765 mp (lsh 0 1 mp)
766 r (lsh 0 1 r)
767 s (lsh 0 1 s)
768 ==
769 =+ [k=--0 q=(^div (^add s 9) 10)]
770 |- ?: (^lth r q)
771 %= $
772 k (dif:si k --1)
773 r (^mul r 10)
774 mn (^mul mn 10)
775 mp (^mul mp 10)
776 ==
777 |- ?: (gte (^add (^mul r 2) mp) (^mul s 2))
778 $(s (^mul s 10), k (sum:si k --1))
779 =+ [u=0 o=0]
780 |- :: r/s+o = a*10^-k
781 =+ v=(dvr (^mul r 10) s)
782 => %= .
783 k (dif:si k --1)
784 u p.v
785 r q.v
786 mn (^mul mn 10)
787 mp (^mul mp 10)
788 ==
789 =+ l=(^lth (^mul r 2) mn) :: in lower bound
790 =+ ^= h :: in upper bound
791 ?| (^lth (^mul s 2) mp)
792 (gth (^mul r 2) (^sub (^mul s 2) mp))
793 ==
794 ?: &(!l !h)
795 $(o (^add (^mul o 10) u))
796 =+ q=&(h |(!l (gth (^mul r 2) s)))
797 =. o (^add (^mul o 10) ?:(q +(u) u))
798 [k o]
799```
801#### Examples
803```
804 > (sun:fl 218.116)
805 [%f s=%.y e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488]
806 > (^drg:fl [e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488])
807 [--0 218.116]
809 > (sun:fl 102.057.673.128.349)
810 [%f s=%.y e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936]
811 > (^drg:fl [e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936])
812 [--0 102.057.673.128.349]
813```
815---
816### `++toj:fl`
818Round to integer
820Rounds float `a` to the nearest decimal float with an exponent of 0.
822#### Accepts
824`a` is a cell of a signed integer and an unsigned integer.
826#### Produces
828An `fn`.
830#### Source
832```
833 ++ toj
834 |= [a=[e=@s a=@u]] ^- fn
835 ?. =((cmp:si e.a --0) -1) [%f & a]
836 =+ x=(abs:si e.a)
837 =+ y=(rsh 0 x a.a)
838 ?: |(=(r %d) =(r %z)) [%f & --0 y]
839 =+ z=(end 0 x a.a)
840 ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))]
841 =+ i=(bex (dec x))
842 ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y]
843 ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)]
844```
846#### Examples
848```
849 > (^toj:fl [-11 7.530.107.827.833.587])
850 [%f s=%.y e=--0 a=3.676.810.462.809]
852 > (^toj:fl [-11 7.530.107.827.833.589])
853 [%f s=%.y e=--0 a=3.676.810.462.809]
854```
856---
857### `++ned:fl`
859Require float
861Produces `a` if `a` is a is of floating-point representation. If `a` is another
862case of `fn`, such as infinity or not-a-number, a crash is produced.
864#### Accepts
866`a` is an `fn`.
868#### Produces
870A cell of a signed integer and an unsigned integer.
872#### Source
874```
875 ++ ned
876 |= [a=fn] ^- [$f s=? e=@s a=@u]
877 ?: ?=([$f *] a) a
878 ~_ leaf+"need-float"
879 !!
880```
882#### Examples
885```
886 > (ned:fl [%f s=%.y e=-11 a=7.530.107.827.833.587])
887 [%f s=%.y e=-11 a=7.530.107.827.833.587]
889 > (ned:fl [%n ~])
890 ! need-float
891 ! exit
893 > (ned:fl [%i |])
894 ! need-float
895 ! exit
896```
898---
899### `++shf:fl`
901Shift power
903Multiplies `a` by 2 to the `b` power without rounding. This results in shifting
904the exponent term by `b`.
906#### Accepts
908`a` is an `fn`.
910`b` is a signed integer.
912#### Produces
914An `fn`.
916#### Source
918```
919 ++ shf
920 |= [a=fn b=@s]
921 ?: |(?=([$n *] a) ?=([$i *] a)) a
922 a(e (sum:si e.a b))
923```
925#### Examples
927```
928 > (shf:fl [[%f & -2 7] --2])
929 [%f s=%.y e=--0 a=7]
931 > (shf:fl [[%f & -2 7] -2])
932 [%f s=%.y e=-4 a=7]
934 > (shf:fl [%f & -11 7.530.107.827.833.587] --5)
935 [%f s=%.y e=-6 a=7.530.107.827.833.587]
936```
938---
939### `++fli:fl`
941Flip sign
943Produces `a` with its signed changed from positive to negative, or vice versa.
945#### Accepts
947`a` is an `fn`.
949#### Produces
951An `fn`.
953#### Source
955```
956 ++ fli
957 |= [a=fn] ^- fn
958 ?-(-.a $f a(s !s.a), $i a(s !s.a), $n a)
959```
961#### Examples
963```
964 > (fli:fl [%f %.y -2 7])
965 [%f s=%.n e=-2 a=7]
967 > (fli:fl [%f %.n --2 30.617])
968 [%f s=%.y e=--2 a=30.617]
970 > (fli:fl [%f | --2 30.617])
971 [%f s=%.y e=--2 a=30.617]
972```
974---
975### `++swr:fl`
977Switch rounding
979Switches the rounding mode of `r:fl`.
981#### Source
983```
984 ++ swr ?+(r r $d %u, $u %d)
985```
987#### Examples
989```
990 > r:fl
991 %n
992 > swr:fl
993 %n
995 > =new-fl fl :: new fl core with changed state
996 > =new-fl new-fl(r %u)
997 > swr:new-fl
998 %d
999```
1001---
1002### `++prc:fl`
1004Force precision of 2 or greater
1006Produces `p`, the core's precision, if `p` is greater than or equal to 2.
1007Otherwise, a crash is produced.
1009#### Source
1011```
1012 ++ prc ?>((gth p 1) p)
1013```
1015#### Examples
1017```
1018 > prc:fl
1019 113
1021 > =new-fl fl
1022 > =new-fl new-fl(p 1)
1023 > prc:new-fl
1024 ! exit
1026 > =new-fl new-fl(p 2)
1027 > prc:new-fl
1029```
1031---
1032### `++den:fl`
1034Behavior
1036Produces `d:fl`. Denormalizes if `d:fl` is `%d`. Flushes denormals to zero if
1037`d:fl` is `%f`.
1039- Denormalizes if `d:fl` is `%d`.
1040- Flushes denormals to zero if `d:fl` is `%f`.
1041- Infinite exponent range if `$d` is `$i`.
1043The default value of `d` is `%d`.
1045#### Source
1047```
1048 ++ den d
1049```
1051#### Examples
1053```
1054 > den:fl
1055 %d
1057 > =new-fl fl
1058 > =new-fl new-fl(d %f)
1059 > den:new-fl
1060 %f
1061```
1063---
1064### `++emn:fl`
1066Minimum exponent
1068Produces `v:fl`, the minimum exponent. The default minimum exponent is -16.494.
1070#### Source
1072```
1073 ++ emn v
1074```
1076#### Examples
1078```
1079 > emn:fl
1080 -16.494
1081```
1083---
1084### `++emx:fl`
1086Maximum exponent
1088Returns the maximum exponent of `fl`. The default maximum exponent is --16.271.
1090#### Source
1092```
1093 ++ emx (sum:si emn (sun:si w))
1094```
1096#### Examples
1098```
1099 > emx:fl
1100 --16.271
1102 > `@u`emx:fl
1103 32.542
1104```
1106---
1107### `++spd:fl`
1109Smallest denormal
1111Produces the smallest possible denormalized float.
1113#### Source
1115```
1116 ++ spd [e=emn a=1]
1117```
1119#### Examples
1121```
1122 > spd:fl
1123 [e=-16.494 a=1]
1124```
1126---
1127### `++spn:fl`
1129Smallest normal
1131Produces the smallest representable normal float.
1133#### Source
1135```
1136 ++ spn [e=emn a=(bex (dec prc))]
1137```
1139#### Examples
1141```
1142 > spn:fl
1143 [e=-16.494 a=5.192.296.858.534.827.628.530.496.329.220.096]
1144```
1146---
1147### `++lfn:fl`
1149Largest normal
1151Produces the largest representable normal float.
1153#### Source
1155```
1156 ++ lfn [e=emx a=(fil 0 prc 1)]
1157```
1159#### Examples
1161```
1162 > lfn:fl
1163 [e=--16.271 a=10.384.593.717.069.655.257.060.992.658.440.191]
1164```
1166---
1167### `++lfe:fl`
1169Maximum
1171Produces the sum of `emx:fl` plus `prc:fl`.
1173#### Source
1175```
1176 ++ lfe (sum:si emx (sun:si prc)) :: 2^lfe is > than all
1177```
1179#### Examples
1181```
1182 > lfe:fl
1183 --16.384
1184```
1186---
1187### `++zer:fl`
1189Zero
1191Produces zero represented as a float.
1193#### Source
1195```
1196 ++ zer [e=--0 a=0]
1197 --
1198 |%
1199```
1201#### Examples
1203```
1204 > zer:fl
1205 [e=--0 a=0]
1206```
1208---
1209### `++rou:fl`
1211Round
1213Rounds `a`. The way in which `a` is rounded depends on the value of `r:fl`.
1215#### Accepts
1217`a` is an `fn`.
1219#### Produes
1221An `fn`.
1223#### Source
1225```
1226 ++ rou
1227 |= [a=fn] ^- fn
1228 ?. ?=([$f *] a) a
1229 ?~ a.a [%f s.a zer]
1230 ?: s.a (^rou +>.a)
1231 =.(r swr (fli (^rou +>.a)))
1232```
1234#### Examples
1236```
1237 > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
1238 > (rou:fl [%f & --12 a])
1239 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1241 > (rou:fl [%f & --12 (add a 1)])
1242 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1244 > (rou:fl [%f & --12 (add a 300)])
1245 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1247 > (rou:fl [%f & --12 (add a 1.000)])
1248 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
1249```
1251---
1252### `++syn:fl`
1254Get sign
1256Produces the sign of `a`.
1258#### Accepts
1260`a` is an `fn`.
1262#### Produes
1264An `fn`.
1266#### Source
1268```
1269 ++ syn
1270 |= [a=fn] ^- ?
1271 ?-(-.a $f s.a, $i s.a, $n &)
1272```
1274#### Examples
1276```
1277 > (syn:fl (sun:fl 106))
1278 %.y
1280 > (syn:fl [%f | --0 106])
1281 %.n
1282```
1284---
1285### `++abs:fl`
1287Absolute value
1289Produces the absolute value of `a`.
1291#### Accepts
1293`a` is an `fn`.
1295#### Produes
1297An `fn`.
1299#### Sources
1301```
1302 ++ abs
1303 |= [a=fn] ^- fn
1304 ?: ?=([$f *] a) [%f & e.a a.a]
1305 ?: ?=([$i *] a) [%i &] [%n ~]
1306```
1308#### Examples
1310```
1311 > (abs:fl [%f | --0 106])
1312 [%f s=%.y e=--0 a=106]
1314 > (abs:fl [%f & --0 106])
1315 [%f s=%.y e=--0 a=106]
1316```
1318---
1319### `++add:fl`
1321Add
1323Produces the sum of `a` plus `b`.
1325#### Accepts
1327`a` is an `fn`.
1329`b` is an `fn`.
1331#### Produces
1333An `fn`.
1335#### Source
1337```
1338 ++ add
1339 |= [a=fn b=fn] ^- fn
1340 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1341 ?: |(?=([$i *] a) ?=([$i *] b))
1342 ?: &(?=([$i *] a) ?=([$i *] b))
1343 ?: =(a b) a [%n ~]
1344 ?: ?=([$i *] a) a b
1345 ?: |(=(a.a 0) =(a.b 0))
1346 ?. &(=(a.a 0) =(a.b 0)) %- rou ?~(a.a b a)
1347 [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer]
1348 %- |= [a=fn]
1349 ?. ?=([$f *] a) a
1350 ?. =(a.a 0) a
1351 [%f !=(r %d) zer]
1352 ?: =(s.a s.b)
1353 ?: s.a (^add +>.a +>.b |)
1354 =.(r swr (fli (^add +>.a +>.b |)))
1355 ?: s.a (^sub +>.a +>.b |)
1356 (^sub +>.b +>.a |)
1357```
1359#### Examples
1361```
1362 > (add:fl [%f & --0 106] [%f | --3 55])
1363 [%f s=%.n e=-104 a=6.774.324.807.619.657.921.598.381.929.529.344]
1364```
1366---
1367### `++ead:fl`
1369Exact add
1371Produces the exact sum of `a` plus `b`.
1373#### Accepts
1375`a` is an `fn`.
1377`b` is an `fn`.
1379#### Produces
1381An `fn`.
1383#### Source
1385```
1386 ++ ead
1387 |= [a=fn b=fn] ^- fn
1388 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1389 ?: |(?=([$i *] a) ?=([$i *] b))
1390 ?: &(?=([$i *] a) ?=([$i *] b))
1391 ?: =(a b) a [%n ~]
1392 ?: ?=([$i *] a) a b
1393 ?: |(=(a.a 0) =(a.b 0))
1394 ?. &(=(a.a 0) =(a.b 0)) ?~(a.a b a)
1395 [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer]
1396 %- |= [a=fn]
1397 ?. ?=([$f *] a) a
1398 ?. =(a.a 0) a
1399 [%f !=(r %d) zer]
1400 ?: =(s.a s.b)
1401 ?: s.a (^add +>.a +>.b &)
1402 (fli (^add +>.a +>.b &))
1403 ?: s.a (^sub +>.a +>.b &)
1404 (^sub +>.b +>.a &)
1405 ::
1406```
1408#### Examples
1410```
1411 > (ead:fl [%f & --0 106] [%f | --3 55])
1412 [%f s=%.n e=--0 a=334]
1413```
1415---
1416### `++sub:fl`
1418Subtract
1420Produces the difference of `a` minus `b`.
1422#### Accepts
1424`a` is an `fn`.
1426`b` is an `fn`.
1428#### Produces
1430An `fn`.
1432#### Source
1434```
1435 ++ sub
1436 |= [a=fn b=fn] ^- fn (add a (fli b))
1437```
1439#### Examples
1441```
1442 > (sub:fl [%f & --13 2.718] [%f & --23 11])
1443 [%f s=%.n e=-86 a=5.416.671.014.775.224.232.595.412.796.571.648]
1444```
1446---
1447### `++mul:fl`
1449Multiply
1451Produces the product of `a` multiplied by `b`.
1453#### Accepts
1455`a` is an `fn`.
1457`b` is an `fn`.
1459#### Produces
1461An `fn`.
1463#### Source
1465```
1466 ++ mul
1467 |= [a=fn b=fn] ^- fn
1468 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1469 ?: ?=([$i *] a)
1470 ?: ?=([$i *] b)
1471 [%i =(s.a s.b)]
1472 ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1473 ?: ?=([$i *] b)
1474 ?: =(a.a 0) [%n ~] [%i =(s.a s.b)]
1475 ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer]
1476 ?: =(s.a s.b) (^mul +>.a +>.b)
1477 =.(r swr (fli (^mul +>.a +>.b)))
1478```
1480---
1481### `++emu:fl`
1483Exact multiply
1485Produces the exact product of `a` multiplied by `b`.
1487#### Accepts
1489`a` is an `fn`.
1491`b` is an `fn`.
1493#### Produces
1495An `fn`.
1497#### Examples
1499```
1500 ++ emu
1501 |= [a=fn b=fn] ^- fn
1502 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1503 ?: ?=([$i *] a)
1504 ?: ?=([$i *] b)
1505 [%i =(s.a s.b)]
1506 ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1507 ?: ?=([$i *] b)
1508 ?: =(a.a 0) [%n ~] [%i =(s.a s.b)]
1509 ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer]
1510 [%f =(s.a s.b) (sum:si e.a e.b) (^^mul a.a a.b)]
1511```
1513---
1514### `++div:fl`
1516Divide
1518Produces the quotient of `a` divided by `b`.
1520#### Accepts
1522`a` is an `fn`.
1524`b` is an `fn`.
1526#### Produces
1528An `fn`.
1530#### Divide
1532```
1533 ++ div
1534 |= [a=fn b=fn] ^- fn
1535 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1536 ?: ?=([$i *] a)
1537 ?: ?=([$i *] b) [%n ~] [%i =(s.a s.b)]
1538 ?: ?=([$i *] b) [%f =(s.a s.b) zer]
1539 ?: =(a.a 0) ?: =(a.b 0) [%n ~] [%f =(s.a s.b) zer]
1540 ?: =(a.b 0) [%i =(s.a s.b)]
1541 ?: =(s.a s.b) (^div +>.a +>.b)
1542 =.(r swr (fli (^div +>.a +>.b)))
1543```
1545---
1546### `++fma:fl`
1548Fused multiply-add
1550Produces the sum of `c` plus the product of `a` multiplied by `b`;
1551`(a * b) + c`.
1553#### Accepts
1555`a` is an `fn`.
1557`b` is an `fn`.
1559`c` is an `fn`.
1561#### Produces
1563An `fn`.
1565#### Source
1567```
1568 ++ fma
1569 |= [a=fn b=fn c=fn] ^- fn
1570 (add (emu a b) c)
1571```
1573#### Examples
1575```
1576 > (fma:fl [%f & --13 2.718] [%f & --23 11] [%f & --13 2.718])
1577 [%f s=%.y e=-62 a=9.475.054.514.089.037.465.004.673.635.188.736]=
1578```
1580---
1581### `++sqt:fl`
1583Square root
1585Produces the square root of `a`.
1587#### Accepts
1589`a` is an `fn`.
1591#### Produces
1593An `fn`.
1595#### Source
1597```
1598 ++ sqt
1599 |= [a=fn] ^- fn
1600 ?: ?=([$n *] a) [%n ~]
1601 ?: ?=([$i *] a) ?:(s.a a [%n ~])
1602 ?~ a.a [%f s.a zer]
1603 ?: s.a (^sqt +>.a) [%n ~]
1604```
1606#### Examples
1608```
1609 > (sqt:fl [%f s=%.y e=-18 a=342.602.577])
1610 [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
1611```
1613---
1614### `++inv:fl`
1616Inverse
1618Produces the inverse of `a` by dividing `1` by `a`.
1620#### Accepts
1622`a` is an `fn`.
1624#### Produces
1626An `fn`.
1628#### Source
1630```
1631 ++ inv
1632 |= [a=fn] ^- fn
1633 (div [%f & --0 1] a)
1634```
1636#### Examples
1638```
1639 > (inv:fl [%f s=%.y e=--0 a=10])
1640 [%f s=%.y e=-116 a=8.307.674.973.655.724.205.648.794.126.752.154]
1641 > (drg:fl [%f s=%.y e=-116 a=8.307.674.973.655.724.205.648.794.126.752.154])
1642 [%d s=%.y e=-1 a=1]
1644 > (inv:fl [%f s=%.y e=--1 a=10])
1645 [%f s=%.y e=-117 a=8.307.674.973.655.724.205.648.794.126.752.154]
1646 > (drg:fl [%f s=%.y e=-117 a=8.307.674.973.655.724.205.648.794.126.752.154])
1647 [%d s=%.y e=-2 a=5]
1649 > (inv:fl [%f s=%.y e=--2 a=10])
1650 [%f s=%.y e=-118 a=8.307.674.973.655.724.205.648.794.126.752.154]
1651 > (drg:fl [%f s=%.y e=-118 a=8.307.674.973.655.724.205.648.794.126.752.154])
1652 [%d s=%.y e=-3 a=25]
1653```
1655---
1656### `++sun:fl`
1658Signed integer to float
1660Produces `a` in floating-point representation.
1662#### Accepts
1664`a` is an unsigned integer.
1666#### Produces
1668An `fn`.
1670#### Source
1672```
1673 ++ sun
1674 |= [a=@u] ^- fn
1675 (rou [%f & --0 a])
1676```
1678#### Examples
1680```
1681 > (sun:fl 0)
1682 [%f s=%.y e=--0 a=0]
1684 > (sun:fl 5.048.729)
1685 [%f s=%.y e=-90 a=6.250.023.776.601.238.669.911.180.544.311.296]
1687 > (sun:fl -100)
1688 ! exit
1689```
1691---
1692### `++san:fl`
1694Signed integer to float
1696Produces the floating-point representation of `a`, an unsigned integer.
1698#### Accepts
1700`a` is an unsigned integer.
1702#### Produces
1704An `fn`.
1706#### Source
1708```
1709 ++ san
1710 |= [a=@s] ^- fn
1711 =+ b=(old:si a)
1712 (rou [%f -.b --0 +.b])
1713```
1715#### Examples
1717```
1718 > (san:fl --100)
1719 [%f s=%.y e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1721 > (san:fl -100)
1722 [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1723```
1725---
1726### `++lth:fl`
1728Less than
1730Tests if `a` is less than `b`. Returns `~` in the event of `a` or `b` being a
1731NaN (`[%n ~]`).
1733#### Accepts
1735`a` is an `fn`.
1737`b` is an `fn`.
1739#### Produces
1741A `unit` of `flag`.
1743#### Source
1745```
1746 ++ lth
1747 |= [a=fn b=fn] ^- (unit ?)
1748 ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1749 ?: =(a b) |
1750 ?: ?=([$i *] a) !s.a ?: ?=([$i *] b) s.b
1751 ?: |(=(a.a 0) =(a.b 0))
1752 ?: &(=(a.a 0) =(a.b 0)) |
1753 ?: =(a.a 0) s.b !s.a
1754 ?: !=(s.a s.b) s.b
1755 ?: s.a (^lth +>.a +>.b) (^lth +>.b +>.a)
1756```
1758#### Examples
1760```
1761 > (lth:fl (sun:fl 116) (sun:fl 4.820))
1762 [~ u=%.y]
1764 > (lth:fl (sun:fl 218.116) (sun:fl 4.820))
1765 [~ u=%.n]
1767 > (lth:fl (sun:fl 218.116) [%n ~])
1769```
1771---
1772### `++lte:fl`
1774Less than or equal
1776Tests whether `a` is less than or equal to `b`. Returns `~` in the event of `a`
1777or `b` being a NaN (`[%n ~]`).
1779#### Accepts
1781`a` is an `fn`.
1783`b` is an `fn`.
1785#### Produces
1787A `unit` of `flag`.
1789#### Source
1791```
1792 ++ lte
1793 |= [a=fn b=fn] ^- (unit ?)
1794 %+ bind (lth b a) |= a=? !a
1795```
1797#### Examples
1799```
1800 > (lte:fl (sun:fl 102) [%f %.y -5 973.655.724])
1801 [~ u=%.y]
1803 > (lte:fl (sun:fl 102) [%f %.y -24 973.655.724])
1804 [~ u=%.n]
1806 > (lte:fl [%f %.y --2 25] (sun:fl 100))
1807 [~ u=%.y]
1809 > (lte:fl [%f %.y --2 25] [%f %.y --3 2])
1810 [~ u=%.n]
1812 > (lte:fl [%f %.y --2 25] [%n ~])
1814```
1816---
1817### `++equ:fl`
1819Equals
1821Tests if `a` is equal to `b`. Returns `~` in the event of `a` or `b` being a NaN
1822(`[%n ~]`).
1824#### Accepts
1826`a` is an `fn`.
1828`b` is an `fn`.
1830#### Produces
1832An `unit` of `flag`.
1834#### Source
1836```
1837 ++ equ
1838 |= [a=fn b=fn] ^- (unit ?)
1839 ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1840 ?: =(a b) &
1841 ?: |(?=([$i *] a) ?=([$i *] b)) |
1842 ?: |(=(a.a 0) =(a.b 0))
1843 ?: &(=(a.a 0) =(a.b 0)) & |
1844 ?: |(=(e.a e.b) !=(s.a s.b)) |
1845 (^equ +>.a +>.b)
1846```
1848#### Examples
1850```
1851 > (equ:fl [%f %.y --2 25] (sun:fl 100))
1852 [~ u=%.y]
1854 > (equ:fl [%f %.y --2 25] (sun:fl 101))
1855 [~ u=%.n]
1856```
1858---
1859### `++gte:fl`
1861Greater or equal than
1863Tests whether `a` is greater than or equal to `b`. Returns `~` in the event of
1864`a` or `b` being a NaN (`[%n ~]`).
1866#### Accepts
1868`a` is an `fn`.
1870`b` is an `fn`.
1872#### Produces
1874An `unit` of `flag`.
1876#### Source
1878```
1879 ++ gte
1880 |= [a=fn b=fn] ^- (unit ?) (lte b a)
1881```
1883#### Examples
1885```
1886 > (gte:fl [%f %.y --2 25] (sun:fl 100))
1887 [~ u=%.y]
1889 > (gth:fl [%f %.y --6 73.989] [%f %.y --5 919.599])
1890 [~ u=%.n]
1892 > (gth:fl [%f %.y --6 73.989] [%n ~])
1894```
1896---
1897### `++gth:fl`
1899Greater than
1901Tests whether `a` is greater than `b`. Returns `~` in the event of `a` or `b`
1902being a NaN (`[%n ~]`).
1904#### Accepts
1906`a` is an `fn`.
1908`b` is an `fn`.
1910#### Produces
1912An `unit` of `flag`.
1914#### Source
1916```
1917 ++ gth
1918 |= [a=fn b=fn] ^- (unit ?) (lth b a)
1919```
1921#### Examples
1923```
1924 > (gth:fl [%f %.y --2 25] (sun:fl 100))
1925 [~ u=%.n]
1927 > (gth:fl [%f %.y --6 73.989] [%f %.y --5 119.599])
1928 [~ u=%.y]
1929```
1931---
1932### `++drg:fl`
1934Float to decimal
1936Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
1937accurate results for rounded floats.
1939#### Accepts
1941`a` is an `fn`.
1943#### Produces
1945A `dn`.
1947#### Source
1949```
1950 ++ drg
1951 |= [a=fn] ^- dn
1952 ?: ?=([$n *] a) [%n ~]
1953 ?: ?=([$i *] a) [%i s.a]
1954 ?~ a.a [%d s.a --0 0]
1955 [%d s.a (^drg +>.a)]
1956```
1958#### Examples
1960```
1961 > (drg:fl [%f | --6 73.989])
1962 [%d s=%.n e=--0 a=4.735.296]
1963```
1965---
1966### `++grd:fl`
1968Decimal to float
1970Converts decimal `a` to `fn`.
1972#### Accepts
1974`a` is a `dn`.
1976#### Produces
1978An `fn`.
1980#### Source
1982```
1983 ++ grd
1984 |= [a=dn] ^- fn
1985 ?: ?=([$n *] a) [%n ~]
1986 ?: ?=([$i *] a) [%i s.a]
1987 => .(r %n)
1988 =+ q=(abs:si e.a)
1989 ?: (syn:si e.a)
1990 (mul [%f s.a --0 a.a] [%f & e.a (pow 5 q)])
1991 (div [%f s.a --0 a.a] [%f & (sun:si q) (pow 5 q)])
1992```
1994#### Examples
1996```
1997 > (grd:fl [%d s=%.n e=--0 a=73.989])
1998 [%f s=%.n e=-96 a=5.862.012.516.267.904.074.208.723.341.410.304]
2000 > (grd:fl [%d s=%.n e=--0 a=100])
2001 [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
2002```
2004---
2005### `++toi:fl`
2007Round to signed integer
2009Rounds `a` to the nearest signed integer.
2011#### Accepts
2013`a` is an `fn`.
2015#### Produces
2017A `unit` of @s.
2019#### Source
2021```
2022 ++ toi
2023 |= [a=fn] ^- (unit @s)
2024 =+ b=(toj a)
2025 ?. ?=([$f *] b) ~ :- ~
2026 =+ c=(^^mul (bex (abs:si e.b)) a.b)
2027 (new:si s.b c)
2028```
2030#### Examples
2032```
2033 > (toi:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514.406.400])
2034 [~ u=--26.843.545.600]
2035```
2037---
2038### `++toj:fl`
2040Round to integer fn
2042Rounds `a` to the nearest decimal integer.
2044#### Accepts
2046`a` is an `fn`.
2048#### Produces
2050A `unit` of @s.
2052#### Source
2054```
2055 ++ toj
2056 |= [a=fn] ^- fn
2057 ?. ?=([$f *] a) a
2058 ?~ a.a [%f s.a zer]
2059 ?: s.a (^toj +>.a)
2060 =.(r swr (fli (^toj +>.a)))
2061 --
2062```
2064#### Examples
2066```
2067 > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514.406.400])
2068 [%f s=%.y e=--0 a=26.843.545.600]
2070 > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514])
2071 [%f s=%.y e=--0 a=26.844]
2073 > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460])
2074 [%f s=%.y e=--0 a=0]
2076 > (toj:fl [%f s=%.y e=-9 a=9.002])
2077 [%f s=%.y e=--0 a=16]
2078```
2080---
2081### `++ff`
2083IEEE-754 Formatting
2085Container core for IEEE-754 formatting operations.
2087- `w` is width: The number of bits in the exponent field.
2088- `p` is precision: The number of bits in the significand field.
2089- `w` is bias: Added to exponent when storing.
2090- `r` is rounding mode: Possible modes are nearest (`$n`), up (`$u`),
2091 down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%a`.
2093#### Source
2095```
2096 ++ ff
2097 |_ [[w=@u p=@u b=@s] r=$?($n $u $d $z $a)]
2098```
2100#### Examples
2102```
2103 > =ffcore ~(. ff [8 8 0] %n)
2104 > ffcore
2105 <24.ltg {{{@ud @ud @ud} r/$n} <54.tyv 119.wim 31.ohr 1.jmk $143>}>
2107```
2109---
2110#### Discussion
2112`++ff` has no use outside of the functionality provided to other cores: `++rd`,
2113`++rs`, `++rq`, and `++rh`. It's not intended to be used directly; it's just
2114meant to power those cores.
2116---
2117### `++sb:ff`
2119Sign bit
2121Produces the sign bit of `++ff`.
2123#### Source
2125```
2126 ++ sb (bex (^add w p))
2127```
2129#### Examples
2131```
2132 > sb:ff
2134```
2136---
2137### `++me:ff`
2139Minimum exponent
2141Produces the minimum possible exponent of `ff`.
2143#### Source
2145```
2146 ++ me (dif:si (dif:si --1 b) (sun:si p))
2147```
2149#### Examples
2151```
2152 > me:ff
2153 --1
2154```
2156---
2157### `++pa:ff`
2159Initialize `fl`
2161Instantiates the core `fl`, giving values to its samples based on the
2162configuration of the `ff` core.
2164#### Source
2166```
2167 ++ pa
2168 %*(. fl p +(p), v me, w (^sub (bex w) 3), d %d, r r)
2169```
2171#### Examples
2173```
2174 > ~(pa ff [11 52 --1.023] %n)
2175 < 23.qzd
2176 28.btz
2177 { {{p/@ v/@s w/@} r/?($n $u $a $d $z) d/$d}
2178 <54.tyv 119.wim 31.ohr 1.jmk $143>
2181```
2183#### Discussion
2185`++pa` exists exclusively for internal use of `++ff`, and `++ff` exists for
2186internal use in other cores.
2188---
2189### `++sea:ff`
2191`@r` to `fn`
2193Converts `a` from `@r` to `fn`.
2195#### Accepts
2197`a` is a `@r`, an IEEE float.
2199#### Produces
2201A `unit` of @s.
2203#### Source
2205```
2206 ++ sea
2207 |= [a=@r] ^- fn
2208 =+ [f=(cut 0 [0 p] a) e=(cut 0 [p w] a)]
2209 =+ s=(sig a)
2210 ?: =(e 0)
2211 ?: =(f 0) [%f s --0 0] [%f s me f]
2212 ?: =(e (fil 0 w 1))
2213 ?: =(f 0) [%i s] [%n ~]
2214 =+ q=:(sum:si (sun:si e) me -1)
2215 =+ r=(^add f (bex p))
2216 [%f s q r]
2217```
2219#### Examples
2221```
2222 > (sea:ff `@r`0x8)
2223 [%f s=%.y e=--0 a=0]
2224```
2226---
2227### `++bit:ff`
2229`fn` to `@r`, rounding
2231Converts `a` from `fn` to `@r` and applies rounding.
2233#### Accepts
2235`a` is an `fn`.
2237#### Produces
2239A `@r`.
2241#### Source
2243```
2244 ++ bit |= [a=fn] (bif (rou:pa a))
2245```
2247#### Examples
2249```
2250 > (bit:ma:rd [%f | -6 202])
2251 0xc009400000000000
2252```
2254---
2255### `++bif:ff`
2257`fn` to `@r`, no rounding
2259Converts `a` from `fn` to `@r`. No rounding is applied.
2261#### Accepts
2263`a` is a `@r`, an IEEE float.
2265#### Produces
2267A `flag`.
2269#### Source
2271```
2272 ++ bif
2273 |= [a=fn] ^- @r
2274 ?: ?=([$i *] a)
2275 =+ q=(lsh 0 p (fil 0 w 1))
2276 ?: s.a q (^add q sb)
2277 ?: ?=([$n *] a) (lsh 0 (dec p) (fil 0 +(w) 1))
2278 ?~ a.a ?: s.a `@r`0 sb
2279 =+ ma=(met 0 a.a)
2280 ?. =(ma +(p))
2281 ?> =(e.a me)
2282 ?> (^lth ma +(p))
2283 ?: s.a `@r`a.a (^add a.a sb)
2284 =+ q=(sum:si (dif:si e.a me) --1)
2285 =+ r=(^add (lsh 0 p (abs:si q)) (end 0 p a.a))
2286 ?: s.a r (^add r sb)
2287```
2289#### Examples
2291```
2292 > (bif:ma:rd *fn)
2293 0x7ff8000000000000
2294```
2296---
2297### `++sig:ff`
2299Get sign
2301Produces the sign of `a`.
2303#### Accepts
2305`a` is a `@r`, an IEEE float.
2307#### Produces
2309A `flag`.
2311#### Source
2313```
2314 ++ sig
2315 |= [a=@r] ^- ?
2316 =(0 (cut 0 [(^add p w) 1] a))
2317```
2319#### Examples
2321```
2322 > (sig:ff `@r`5)
2323 %.n
2324```
2326---
2327### `++exp:ff`
2329Get exponent
2331Produces the exponent of `a`.
2333#### Accepts
2335`a` is a `@r`, an IEEE float.
2337#### Produces
2339A signed integer.
2341#### Source
2343```
2344 ++ exp
2345 |= [a=@r] ^- @s
2346 (dif:si (sun:si (cut 0 [p w] a)) b)
2347```
2349#### Examples
2351```
2352 > (exp:ff `@r`5)
2353 --0
2354```
2356---
2357### `++add:ff`
2359Add
2361Produces the sum of `a` plus `b`.
2363#### Accepts
2365`a` is a `@r`, an IEEE float.
2367`b` is a `@r`, an IEEE float.
2369#### Produces
2371A `@r`, an IEEE float.
2373#### Source
2375```
2376 ++ add
2377 |= [a=@r b=@r]
2378 (bif (add:pa (sea a) (sea b)))
2379```
2381#### Examples
2383```
2384 > (add:ma:rd `@r`5 `@r`11)
2385 0x10
2386```
2388---
2389### `++sub:ff`
2391Sub
2393Produces the sum of `a` plus `b`.
2395#### Accepts
2397`a` is a `@r`, an IEEE float.
2399`b` is a `@r`, an IEEE float.
2401#### Produces
2403A `@r`, an IEEE float.
2405#### Source
2407```
2408 ++ sub
2409 |= [a=@r b=@r]
2410 (bif (sub:pa (sea a) (sea b)))
2411```
2413#### Examples
2415```
2416 > (sub:ma:rd `@r`5 `@r`11)
2417 0x8000000000000006
2418```
2420---
2421### `++mul:ff`
2423Multiply
2425Produces the product of `a` multiplied by `b`.
2427#### Accepts
2429`a` is a `@r`, an IEEE float.
2431`b` is a `@r`, an IEEE float.
2433#### Produces
2435A `@r`, an IEEE float.
2437#### Multiply
2439```
2440 ++ mul
2441 |= [a=@r b=@r]
2442 (bif (mul:pa (sea a) (sea b)))
2443```
2445#### Examples
2447```
2448 > (mul:ma:rd `@r`11 `@r`2)
2449 0x0
2450```
2452---
2453### `++div:ff`
2455Divide
2457Produces the quotient of `a` divided by `b`.
2459#### Accepts
2461`a` is a `@r`, an IEEE float.
2463`b` is a `@r`, an IEEE float.
2465#### Produces
2467A `@r`, an IEEE float.
2469#### Source
2471```
2472 ++ div
2473 |= [a=@r b=@r]
2474 (bif (div:pa (sea a) (sea b)))
2475```
2477#### Examples
2479```
2480 > (div:ma:rd `@r`175 `@r`26)
2481 0x401aec4ec4ec4ec4
2482```
2484---
2485### `++fma:ff`
2487Fused multiply-add
2489Produces the sum of `c` plus the product of `a` multiplied by `b`;
2490`(a * b) + c`.
2492#### Accepts
2494`a` is a `@r`, an IEEE float.
2496`b` is a `@r`, an IEEE float.
2498`c` is a `@r`, an IEEE float.
2500#### Produces
2502A `@r`, an IEEE float.
2504#### Source
2506```
2507 ++ fma
2508 |= [a=@r b=@r c=@r]
2509 (bif (fma:pa (sea a) (sea b) (sea c)))
2510```
2512#### Examples
2514```
2515 > (fma:ma:rd `@r`175 `@r`26 `@r`100)
2516 0x64
2517```
2519---
2520### `++sqt:ff`
2522Square root
2524Produces the square root of `a`.
2526#### Accepts
2528`a` is a `@r`, an IEEE float.
2530#### Produces
2532A `@r`, an IEEE float.
2534#### Source
2536```
2537 ++ sqt
2538 |= [a=@r]
2539 (bif (sqt:pa (sea a)))
2540```
2542#### Examples
2544```
2545 > (sqt:ma:rd `@r`175)
2546 0x1e9a751f9447b724
2547```
2549---
2550### `++lth:ff`
2552Less than
2554Tests whether `a` is less than `b`.
2556#### Accepts
2558`a` is a `@r`, an IEEE float.
2560`b` is a `@r`, an IEEE float.
2562#### Produces
2564A `flag`.
2566#### Source
2568```
2569 ++ lth
2570 |= [a=@r b=@r] (fall (lth:pa (sea a) (sea b)) |)
2571```
2573#### Examples
2575```
2576 > (lth:ma:rd `@rd`1 `@rd`2)
2577 %.y
2579 > (lth:ma:rd `@rd`10 `@rd`2)
2580 %.n
2581```
2583---
2584### `++lte:ff`
2586Less than or equal to
2588Tests whether `a` is less than or equal to `b`.
2590#### Accepts
2592`a` is a `@r`, an IEEE float.
2594`b` is a `@r`, an IEEE float.
2596#### Produces
2598A `flag`.
2600#### Source
2602```
2603 ++ lte
2604 |= [a=@r b=@r] (fall (lte:pa (sea a) (sea b)) |)
2605```
2607#### Examples
2609```
2610 > (lte:ma:rd `@rd`10 `@rd`2)
2611 %.n
2613 > (lte:ma:rd `@rd`10 `@rd`10)
2614 %.y
2615```
2617---
2618### `++equ:ff`
2620Equals
2622Tests whether `a` is equal to `b`.
2624#### Accepts
2626`a` is a `@r`, an IEEE float.
2628`b` is a `@r`, an IEEE float.
2630#### Produces
2632A `flag`.
2634#### Source
2636```
2637 ++ equ
2638 |= [a=@r b=@r] (fall (equ:pa (sea a) (sea b)) |)
2639```
2641#### Examples
2643```
2644 > (equ:ma:rd `@rd`10 `@rd`2)
2645 %.n
2647 > (equ:ma:rd `@rd`10 `@rd`10)
2648 %.y
2649```
2651---
2652### `++gte:ff`
2654Greater or equal than
2656Tests whether `a` is greater than or equal to `b`.
2658#### Accepts
2660`a` is a `@r`, an IEEE float.
2662`b` is a `@r`, an IEEE float.
2664#### Produces
2666A `flag`.
2668#### Source
2670```
2671 ++ gte
2672 |= [a=@r b=@r] (fall (gte:pa (sea a) (sea b)) |)
2673```
2675#### Examples
2677```
2678 > (gte:ma:rd `@rd`10 `@rd`10)
2679 %.y
2681 > (gte:ma:rd `@rd`10 `@rd`11)
2682 %.n
2683```
2685---
2686### `++gth:ff`
2688Greater than
2690Tests whether `a` is greater than or equal to `b`.
2692#### Accepts
2694`a` is a `@r`, an IEEE float.
2696`b` is a `@r`, an IEEE float.
2698#### Produces
2700A `flag`.
2702#### Source
2704```
2705 ++ gth
2706 |= [a=@r b=@r] (fall (gth:pa (sea a) (sea b)) |)
2707```
2709#### Examples
2711```
2712 > (gth:ma:rd `@rd`10 `@rd`10)
2713 %.n
2715 > (gth:ma:rd `@rd`10 `@rd`9)
2716 %.y
2717```
2719---
2720### `++sun:ff`
2722Unsigned integer to `@r`
2724Converts `a` from an unsigned integer (`@u`) to `@r`.
2726#### Accepts
2728`a` is `@u`, unsigned integer.
2730#### Produces
2732A `@r`, an IEEE float.
2734#### Source
2736```
2737 ++ sun
2738 |= [a=@u] (bit [%f & --0 a])
2739```
2741#### Examples
2743```
2744 > (sun:ma:rd 658.149.282)
2745 0x41c39d47d1000000
2746```
2748---
2749### `++san:ff`
2751Signed integer to `@r`
2753Converts `a` from a signed integer to `@r`.
2755#### Accepts
2757`a` is `@s`, an unsigned integer
2759#### Produces
2761A `@r`, an IEEE float.
2763#### Source
2765```
2766 ++ san
2767 |= [a=@s] (bit [%f (syn:si a) --0 (abs:si a)])
2768```
2770#### Examples
2772```
2773 > (san:ma:rd --10)
2774 0x4024000000000000
2775```
2777---
2778### `++toi:ff`
2780Round to integer
2782Rounds `a` to the nearest signed integer.
2784#### Accepts
2786`a` is a `@r`, an IEEE float.
2788#### Produces
2790A `flag` of `@s`.
2792#### Source
2794```
2795 ++ toi
2796 |= [a=@r] (toi:pa (sea a))
2797```
2799#### Examples
2801```
2802 > (toi:ma:rd `@r`0x4af)
2803 [~ u=--0]
2804```
2806---
2807### `++drg:ff`
2809`@r` to decimal float
2811Converts `a` from `@r` to `dn` using the Dragon4 algorithm.
2813#### Accepts
2815`a` is a `@r`, an IEEE float.
2817#### Produces
2819A `dn`.
2821#### Source
2823```
2824 ++ drg
2825 |= [a=@r] (drg:pa (sea a))
2826```
2828#### Examples
2830```
2831 > (drg:ma:rd `@r`0x41c0)
2832 [%d s=%.y e=-323 a=8.316]
2834 > (drg:ma:rd (sun:ma:rd 658.149.282))
2835 [%d s=%.y e=--0 a=658.149.282]
2836```
2838---
2839### `++grd:ff`
2841Decimal float to `@r`
2843Converts `a` from `dn` to `@r`.
2845#### Accepts
2847`a` is a `dn`.
2849#### Produces
2851A `@r`, an IEEE float.
2853#### Source
2855```
2856 ++ grd
2857 |= [a=dn] (bif (grd:pa a))
2858 --
2859```
2861#### Examples
2863```
2864 > (grd:ma:rd [%d s=%.y e=--0 a=658.149.282])
2865 0x41c39d47d1000000
2866```
2868---
2869### `++rlyd`
2871Prep `@rd` for print
2873Converts `a` from a double-precision binary float to decimal64.
2875#### Accepts
2877`a` is a `@rd`, a double-precision float.
2879#### Produces
2881A `dn`.
2883#### Source
2885```
2886 ++ rlyd |= a=@rd ^- dn (drg:rd a)
2887```
2889#### Examples
2891```
2892 > (rlyd .~2.4703e-320)
2893 [%d s=%.y e=-324 a=24.703]
2894```
2896---
2897### `++rlys`
2899Prep @rs for print
2901Converts `a` from a single-precision binary float to decimal32.
2903#### Accepts
2905`a` is a `@rs`, a single-precision float.
2907#### Produces
2909A `dn`.
2911#### Source
2913```
2914 ++ rlys |= a=@rs ^- dn (drg:rs a)
2915```
2917#### Examples
2919```
2920 > (rlys .1.681557e-39)
2921 [%d s=%.y e=-45 a=1.681.557]
2922```
2924---
2925### `++rlyh`
2927Prep `@rh` for print
2929Converts `a` from a half-precision binary float to decimal16.
2931#### Accepts
2933`a` is a `@rh`, a half-precision float.
2935#### Produces
2937A `dn`.
2939#### Source
2941```
2942 ++ rlyh |= a=@rh ^- dn (drg:rh a)
2943```
2945#### Examples
2947```
2948 > (rlyh .~~3e1)
2949 [%d s=%.y e=--1 a=3]
2950```
2952---
2953### `++rlyq`
2955Prep `@rq` for print
2957Converts `a` from a quad-precision binary float to decimal128.
2959#### Accepts
2961`a` is a `@rq`, a quad-precision float.
2963#### Produces
2965A `dn`.
2967#### Source
2969```
2970 ++ rlyq |= a=@rq ^- dn (drg:rq a)
2971```
2973#### Examples
2975```
2976 > (rlyq .~~~2.2628017865927756787440310766086816e-4343)
2977 [%d s=%.y e=-4.377 a=22.628.017.865.927.756.787.440.310.766.086.816]
2978```
2980---
2981### `++ryld`
2983Finish parsing `@rd`
2985Converts `a` from a decimal float to a double-precision binary float.
2987#### Accepts
2989`a` is a `dn`.
2991#### Produces
2993A a `@rd`, a double-precision float.
2995#### Source
2997```
2998 ++ ryld |= a=dn ^- @rd (grd:rd a)
2999```
3001#### Examples
3003```
3004 > (ryld [%d s=%.y e=-324 a=24.703])
3005 .~2.4703e-320
3006```
3008---
3009### `++ryls`
3011Finish parsing `@rs`
3013Converts `a` from a decimal float to a single-precision binary float.
3015#### Accepts
3017`a` is a `dn`.
3019#### Produces
3021A a `@rs`, a single-precision float.
3023#### Source
3025```
3026 ++ ryls |= a=dn ^- @rs (grd:rs a)
3027```
3029#### Examples
3031```
3032 > (ryls [%d s=%.y e=-324 a=24.703])
3033 .0
3035 > (ryls [%d s=%.y e=-32 a=24.703])
3036 .2.4703e-28
3037```
3039---
3040### `++rylh`
3042Finish parsing `@rh`
3044Converts `a` from a decimal float to a half-precision binary float.
3046#### Accepts
3048`a` is a `dn`.
3050#### Produces
3052A a `@rh`, a half-precision float.
3054#### Source
3056```
3057 ++ rylh |= a=dn ^- @rh (grd:rh a)
3058```
3060#### Examples
3062```
3063 > (rylh [%d s=%.y e=--1 a=703])
3064 .~~7.032e3
3066 > (rylh [%d s=%.y e=--3 a=56])
3067 .~~5.6e4
3069 > (rylh [%d s=%.y e=--4 a=56])
3070 .~~inf
3071```
3073---
3074### `++rylq`
3076Finish parsing `@rq`
3078Converts `a` from a decimal float to a quad-precision binary float.
3080#### Accepts
3082`a` is a `dn`.
3084#### Produces
3086A a `@rq`, a quad-precision float.
3088#### Source
3090```
3091 ++ rylq |= a=dn ^- @rq (grd:rq a)
3092```
3094#### Examples
3096```
3097 > (rylq [%d s=%.y e=-324 a=24.703])
3098 .~~~2.4703e-320
3099```
3101---
3102### `++rd`
3104Double-precision fp
3106A container core for operations related to double-precision binary floats.
3108`++rd` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3109down (`$d`), and round to zero (`$z`).
3111#### Source
3113```
3114 ++ rd
3115 ^?
3116 ~% %rd +> ~
3117 |_ r=$?($n $u $d $z)
3118```
3120---
3121### `++ma:rd`
3123Initialize `ff`
3125Instantiates the core `ff`, giving values to its samples based on the
3126configuration of the `rd` core.
3128#### Source
3130```
3131 ++ ma
3132 %*(. ff w 11, p 52, b --1.023, r r)
3133```
3135#### Examples
3137```
3138 > ~(ma rd %n)
3139 < 24.ltg
3140 {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3142```
3144---
3145### `++sea:rd`
3147`@rd` to `fn`
3149Converts `a` from a double-precision binary float to `fn`.
3151```
3152 ++ sea :: @rd to fn
3153 |= [a=@rd] (sea:ma a)
3154```
3156#### Examples
3158```
3159 > (sea:rd .~4.94066e-319)
3160 [%f s=%.y e=-1.074 a=100.000]
3161```
3163---
3164### `++bit:rd`
3166`fn` to `@rd`
3168Converts `a` from `fn` to a double-precision binary float.
3170#### Accepts
3172`a` is an `fn`.
3174#### Produces
3176A `@rd`, a double-precision float.
3178#### Source
3180```
3181 ++ bit
3182 |= [a=fn] ^- @rd (bit:ma a)
3183```
3185#### Examples
3187```
3188 > (bit:rd [%f s=%.y e=-1.074 a=100.000])
3189 .~4.94066e-319
3190```
3192---
3193### `++add:rd`
3195Add
3197Produces the sum of `a` plus `b`.
3199#### Accepts
3201`a` is a `@rd`, a double-precision float.
3203`b` is a `@rd`, a double-precision float.
3205#### Produces
3207A `@rd`.
3209#### Source
3211```
3212 ++ add ~/ %add
3213 |= [a=@rd b=@rd] ^- @rd
3214 ~_ leaf+"rd-fail"
3215 (add:ma a b)
3216```
3218#### Examples
3220```
3221 > (add:rd .~3.94066e12 .~9.2846e11)
3222 .~4.86912e12
3223```
3225---
3226### `++sub:rd`
3228Subtract
3230Produces the difference of `a` minus `b`.
3232#### Accepts
3234`a` is a `@rd`, a double-precision float.
3236`b` is a `@rd`, a double-precision float.
3238#### Produces
3240A `@rd`.
3242#### Source
3244```
3245 ++ sub ~/ %sub
3246 |= [a=@rd b=@rd] ^- @rd
3247 ~_ leaf+"rd-fail"
3248 (sub:ma a b)
3249```
3251#### Examples
3253```
3254 > (sub:rd .~7.94069e2 .~1.2846e3)
3255 .~-4.9053099999999995e2
3256```
3258---
3259### `++mul:rd`
3261Multiply
3263Produces the product of `a` times `b`.
3265#### Accepts
3267`a` is a `@rd`, a double-precision float.
3269`b` is a `@rd`, a double-precision float.
3271#### Produces
3273A `@rd`.
3275#### Source
3277```
3278 ++ mul ~/ %mul
3279 |= [a=@rd b=@rd] ^- @rd
3280 ~_ leaf+"rd-fail"
3281 (mul:ma a b)
3282```
3284#### Examples
3286```
3287 > (mul:rd .~7.94069e2 .~1.2246e3)
3288 .~9.724168973999998e5
3289```
3291---
3292### `++div:rd`
3294Divide
3296Produces the quotient of `a` divided by `b`.
3298#### Accepts
3300`a` is a `@rd`, a double-precision float.
3302`b` is a `@rd`.
3304#### Produces
3306A `@rd`.
3308#### Source
3310```
3311 ++ div ~/ %div
3312 |= [a=@rd b=@rd] ^- @rd
3313 ~_ leaf+"rd-fail"
3314 (div:ma a b)
3315```
3317#### Examples
3319```
3320 > (div:rd .~7.94099e2 .~1.2246e3)
3321 .~6.484558223093255e-1
3322```
3324---
3325### `++fma:rd`
3327Fused multiply-add
3329Produces the sum of `c` plus the product of `a` multiplied by `b`;
3330`(a * b) + c`.
3332#### Accepts
3334`a` is a `@rd`, an IEEE float.
3336`b` is a `@rd`.
3338`c` is a `@rd`.
3340#### Produces
3342A `@rd`.
3344#### Source
3347#### Source
3349```
3350 ++ fma ~/ %fma
3351 |= [a=@rd b=@rd c=@rd] ^- @rd
3352 ~_ leaf+"rd-fail"
3353 (fma:ma a b c)
3354```
3356#### Examples
3358```
3359 > (fma:rd .~7.94099e2 .~1.2246e3 .~3.94066e3)
3360 .~9.763942954e5
3361```
3363---
3364### `++sqt:rd`
3366Square root
3368Produces the square root of `a`.
3370#### Accepts
3372`a` is a `@rd`, a double-precision float.
3374#### Produces
3376A `@rd`.
3378#### Source
3380```
3381 ++ sqt ~/ %sqt
3382 |= [a=@rd] ^- @rd ~_ leaf+"rd-fail"
3383 (sqt:ma a)
3384```
3386#### Examples
3388```
3389 > (sqt:rd .~3.94066e3)
3390 .~6.2774676422901614e1
3391```
3393---
3394### `++lth:rd`
3396Less than
3398Test whether `a` is less than `b`.
3400#### Accepts
3402`a` is a `@rd`, a double-precision float.
3404`b` is a `@rd`, a double-precision float.
3406#### Produces
3408A `@rd`.
3410#### Source
3412```
3413 ++ lth ~/ %lth
3414 |= [a=@rd b=@rd]
3415 ~_ leaf+"rd-fail"
3416 (lth:ma a b)
3417```
3419#### Examples
3421```
3422 > (lth:rd .~7.94099e2 .~1.2246e3)
3423 %.y
3425 > (lth:rd .~7.94099e2 .~1.2246e2)
3426 %.n
3428 > (lth:rd .~1.2246e2 .~1.2246e2)
3429 %.n
3430```
3432---
3433### `++lte:rd`
3435Less than or equal
3437Test whether `a` is less than or equal to `b`.
3439#### Accepts
3441`a` is a `@rd`, a double-precision float.
3443`b` is a `@rd`, a double-precision float.
3445#### Produces
3447A `@rd`.
3449#### Source
3451```
3452 ++ lte ~/ %lte :: less-equals
3453 |= [a=@rd b=@rd]
3454 ~_ leaf+"rd-fail"
3455 (lte:ma a b)
3456```
3458#### Examples
3460```
3461 > (lte:rd .~7.94099e2 .~1.2246e3)
3462 %.y
3464 > (lte:rd .~7.94099e2 .~1.2246e2)
3465 %.n
3467 > (lte:rd .~1.2246e2 .~1.2246e2)
3468 %.y
3469```
3471---
3472### `++equ:rd`
3474Equals
3476Test whether `a` is equal to `b`.
3478#### Accepts
3480`a` is a `@rd`, a double-precision float.
3482`b` is a `@rd`, a double-precision float.
3484#### Produces
3486A `@rd`.
3488#### Source
3490```
3491 ++ equ ~/ %equ
3492 |= [a=@rd b=@rd]
3493 ~_ leaf+"rd-fail"
3494 (equ:ma a b)
3495```
3497#### Examples
3499```
3500 > (equ:rd .~7.94099e2 .~1.2246e3)
3501 %.n
3503 > (equ:rd .~7.94099e2 .~1.2246e2)
3504 %.n
3506 > (equ:rd .~1.2246e2 .~1.2246e2)
3507 %.y
3508```
3510---
3511### `++gte:rd`
3513Greater than or equal
3515Test whether `a` is greater than or equal to `b`.
3517#### Accepts
3519`a` is a `@rd`, a double-precision float.
3521`b` is a `@rd`, a double-precision float.
3523#### Produces
3525A `@rd`.
3527#### Source
3529```
3530 ++ gte ~/ %gte
3531 |= [a=@rd b=@rd]
3532 ~_ leaf+"rd-fail"
3533 (gte:ma a b)
3534```
3536#### Examples
3538```
3539 > (gte:rd .~7.94099e2 .~1.2246e3)
3540 %.n
3542 > (gte:rd .~7.94099e2 .~1.2246e2)
3543 %.y
3545 > (gte:rd .~1.2246e2 .~1.2246e2)
3546 %.y
3547```
3549---
3550### `++gth:rd`
3552Greater than
3554Test whether `a` is greater `b`.
3556#### Accepts
3558`a` is a `@rd`, a double-precision float.
3560`b` is a `@rd`, a double-precision float.
3562#### Produces
3564A `@rd`.
3566#### Source
3568```
3569 ++ gth ~/ %gth
3570 |= [a=@rd b=@rd]
3571 ~_ leaf+"rd-fail"
3572 (gth:ma a b)
3573```
3575#### Examples
3577```
3578 > (gth:rd .~7.94099e2 .~1.2246e3)
3579 %.n
3581 > (gth:rd .~7.94099e2 .~1.2246e2)
3582 %.y
3584 > (gth:rd .~1.2246e2 .~1.2246e2)
3585 %.n
3586```
3588---
3589### `++sun:rd`
3591Unsigned integer to `@rd`
3593Converts an unsigned integer `a` to `@rd`.
3595#### Accepts
3597`a` is a `@u`, an unsigned integer.
3599#### Produces
3601A `@rd`.
3603#### Source
3605```
3606 ++ sun |= [a=@u] ^- @rd (sun:ma a)
3607```
3609#### Examples
3611```
3612 > (sun:rd 511)
3613 .~5.11e2
3614```
3616---
3617### `++san:rd`
3619Unsigned integer to `@rd`
3621Converts a signed integer `a` to `@rd`.
3623#### Accepts
3625`a` is a `@s`, a signed integer.
3627#### Produces
3629A `@rd`.
3631#### Source
3633```
3634 ++ san |= [a=@s] ^- @rd (san:ma a)
3635```
3637#### Examples
3639```
3640 > (san:rd -511)
3641 .~-5.11e2
3642```
3644---
3645### `++sig:rd`
3647Get sign
3649Produces the sign of `a`.
3651#### Accepts
3653`a` is a `@rd`
3655#### Produces
3657A `flag`.
3659#### Source
3661```
3662 ++ sig |= [a=@rd] ^- ? (sig:ma a)
3663```
3665#### Examples
3667```
3668 > (sig:rd .~1.2246e3)
3669 %.y
3670```
3672---
3673### `++exp:rd`
3675Get exponent
3677Produces the exponent of `a`.
3679#### Accepts
3681`a` is a `@rd`
3683#### Produces
3685A `@s`.
3687#### Source
3689```
3690 ++ exp |= [a=@rd] ^- @s (exp:ma a) :: get exponent
3691```
3693#### Examples
3695```
3696 > (exp:rd .~1.2246e3)
3697 --10
3698```
3700---
3701### `++toi:rd`
3703Round to integer
3705Rounds `a` to the nearest integer.
3707#### Accepts
3709`a` is a `@rd`
3711#### Produces
3713A `unit` of `@s`.
3715#### Source
3717```
3718 ++ toi |= [a=@rd] ^- (unit @s) (toi:ma a)
3719```
3721#### Examples
3723```
3724 > (toi:rd .~1.2246e3)
3725 [~ u=--1.224]
3726```
3728---
3729### `++drg:rd`
3731`@rd` to decimal float
3733Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
3734accurate results for rounded floats.
3736#### Accepts
3738`a` is a `@rd`
3740#### Produces
3742A `dn`.
3744#### Source
3746```
3747 ++ drg |= [a=@rd] ^- dn (drg:ma a)
3748```
3750#### Examples
3752```
3753 > (drg:rd .~1.2246e3)
3754 [%d s=%.y e=-1 a=12.246]
3755```
3757---
3758### `++grd:rd`
3760Decimal float to `@rd`
3762Converts `a` from decimal float to `@rd`.
3764#### Accepts
3766`a` is a `@dn`
3768#### Produces
3770A `@rd`.
3772#### Source
3774```
3775 ++ grd |= [a=dn] ^- @rd (grd:ma a) :: decimal float to @rd
3776 --
3777```
3779#### Examples
3781```
3782 > (grd:rd [%d s=%.y e=-1 a=12.246])
3783 .~1.2246e3
3784```
3786---
3787### `++rs`
3789Single-precision fp
3791A container core for operations related to single-precision binary floats.
3793`++rs` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3794down (`$d`), and round to zero (`$z`).
3796#### Source
3798```
3799 ++ rs
3800 ~% %rs +> ~
3801 ^?
3802 |_ r=$?($n $u $d $z)
3803```
3805---
3806### `++ma:rs`
3808Initialize `ff`
3810Instantiates the core `ff`, giving values to its samples based on the
3811configuration of the `rs` core.
3813#### Source
3815```
3816 ++ ma
3817 %*(. ff w 8, p 23, b --127, r r)
3818```
3820#### Examples
3822```
3823 > ~(ma rs %n)
3824 < 24.ltg
3825 {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3827```
3829---
3830### `++sea:rs`
3832`@rs` to `fn`
3834Converts `a` from `@rs` to `fn`.
3836#### Accepts
3838`a` is a `@rs`, an single-precision float.
3840#### Produces
3842An `fn`.
3844#### Source
3846```
3847 ++ sea
3848 |= [a=@rs] (sea:ma a)
3849```
3851#### Examples
3853```
3854 > (sea:rs .1.4e-43)
3855 [%f s=%.y e=-149 a=100]
3856```
3858---
3859### `++bit:rs`
3861`fn` to `@rs`
3863Converts `a` from `fn` to `@rs`.
3865#### Accepts
3867`a` is an `fn`.
3869#### Produces
3871A `@rs`, a single-precision float.
3873#### Source
3875```
3876 ++ bit
3877 |= [a=fn] ^- @rs (bit:ma a)
3878```
3880#### Examples
3882```
3883 > (bit:rs [%f & -2 1.000])
3884 .2.5e2
3885```
3887---
3888### `++add:rs`
3890Add
3892Produces the sum of `a` plus `b`.
3894#### Accepts
3896`a` is a `@rs`, a single-precision float.
3898`b` is a `@rs`.
3900#### Produces
3902A `@rs`.
3904#### Source
3906```
3907 ++ add ~/ %add
3908 |= [a=@rs b=@rs] ^- @rs
3909 ~_ leaf+"rs-fail"
3910 (add:ma a b)
3911```
3913#### Examples
3915```
3916 > (add:rs .2.5e1 .2.5e2)
3917 .2.75e2
3918```
3920---
3921### `++sub:rs`
3923Subtract
3925Subtracts `a` from `b`.
3927#### Source
3929```
3930 ++ sub ~/ %sub
3931 |= [a=@rs b=@rs] ^- @rs
3932 ~_ leaf+"rs-fail"
3933 (sub:ma a b)
3934```
3936#### Examples
3938```
3939 > (sub:rs .2.5e1 .2.5e2)
3940 .-2.25e2
3941```
3943---
3944### `++mul:rs`
3946Multiply
3948Produces the product of `a` multiplied by `b`.
3950#### Accepts
3952`a` is a `@rs`, a single-precision float.
3954`b` is a `@rs`.
3956#### Produces
3958A `@rs`.
3960#### Source
3962```
3963 ++ mul ~/ %mul
3964 |= [a=@rs b=@rs] ^- @rs
3965 ~_ leaf+"rs-fail"
3966 (mul:ma a b)
3967```
3969#### Examples
3971```
3972 > (mul:rs .2.5e1 .2.5e2)
3973 .6.25e3
3974```
3976---
3977### `++div:rs`
3979Divide
3981Produces the quotient of `a` divided by `b`.
3983#### Accepts
3985`a` is a `@rs`, a single-precision float.
3987`b` is a `@rs`.
3989#### Produces
3991A `@rs`.
3993#### Source
3995```
3996 ++ div ~/ %div
3997 |= [a=@rs b=@rs] ^- @rs
3998 ~_ leaf+"rs-fail"
3999 (div:ma a b)
4000```
4002#### Examples
4004```
4005 > (div:rs .4.5e1 .2.2e2)
4006 .2.0454545e-1
4007```
4009---
4010### `++fma:rs`
4012Fused multiply-add
4014Produces the sum of `c` plus the product of `a` multiplied by `b`;
4015`(a * b) + c`.
4017#### Accepts
4019`a` is a `@rs`, a single-precision float.
4021`b` is a `@rs`.
4023`c` is a `@rs`.
4025#### Produces
4027A `@rs`.
4029#### Source
4031```
4032 ++ fma ~/ %fma
4033 |= [a=@rs b=@rs c=@rs] ^- @rs
4034 ~_ leaf+"rs-fail"
4035 (fma:ma a b c)
4036```
4038#### Examples
4040```
4041 > (fma:rs .2.5e1 .2.5e2 .8.2e1)
4042 .6.332e3
4043```
4045---
4046### `++sqt:rs`
4048Square root
4050Produces the square root of `a`.
4052#### Accepts
4054`a` is a `@rs`, a single-precision float.
4056#### Produces
4058A `@rs`.
4060#### Source
4062```
4063 ++ sqt ~/ %sqt
4064 |= [a=@rs] ^- @rs
4065 ~_ leaf+"rs-fail"
4066 (sqt:ma a)
4067```
4069#### Examples
4071```
4072 > (sqt:rs .2.5e2)
4073 .1.5811388e1
4074```
4076---
4077### `++lth:rs`
4079Less than
4081Test whether `a` is less than `b`.
4083#### Accepts
4085`a` is a `@rs`, a single-precision float.
4087`b` is a `@rs`.
4089#### Produces
4091A `@rs`.
4093#### Source
4095```
4096 ++ lth ~/ %lth
4097 |= [a=@rs b=@rs]
4098 ~_ leaf+"rs-fail"
4099 (lth:ma a b)
4100```
4102#### Examples
4104```
4105 > (lth:rs .9.9e1 .1.1e2)
4106 %.y
4108 > (lth:rs .9.9e1 .9.9e1)
4109 %.n
4110```
4112---
4113### `++lte:rs`
4115Less than or equal
4117Test whether `a` is less than or equal to `b`.
4119#### Accepts
4121`a` is a `@rs`, a single-precision float.
4123`b` is a `@rs`.
4125#### Produces
4127A `@rs`.
4129#### Source
4131```
4132 ++ lte ~/ %lte
4133 |= [a=@rs b=@rs]
4134 ~_ leaf+"rs-fail"
4135 (lte:ma a b)
4136```
4138#### Examples
4140```
4141 > (lte:rs .9.9e1 .1.1e2)
4142 %.y
4144 > (lte:rs .9.9e1 .9.9e1)
4145 %.y
4146```
4148---
4149### `++equ:rs`
4151Equals
4153Test whether `a` is equal to `b`.
4155#### Accepts
4157`a` is a `@rs`, a single-precision float.
4159`b` is a `@rs`.
4161#### Produces
4163A `@rs`.
4165#### Source
4167```
4168 ++ equ ~/ %equ
4169 |= [a=@rs b=@rs]
4170 ~_ leaf+"rs-fail"
4171 (equ:ma a b)
4172```
4174#### Examples
4176```
4177 > (equ:rs .9.9e1 .1.1e2)
4178 %.n
4180 > (equ:rs .9.9e1 .9.9e1)
4181 %.y
4182```
4184---
4185### `++gte:rs`
4187Greater than or equal
4189Test whether `a` is greater than or equal to `b`.
4191#### Accepts
4193`a` is a `@rs`, a single-precision float.
4195`b` is a `@rs`.
4197#### Produces
4199A `@rs`.
4201#### Source
4203```
4204 ++ gte ~/ %gte
4205 |= [a=@rs b=@rs]
4206 ~_ leaf+"rs-fail"
4207 (gte:ma a b)
4208```
4210#### Examples
4212```
4213 > (gte:rs .9.9e1 .9.9e1)
4214 %.y
4216 > (gte:rs .9.9e1 .9.2e2)
4217 %.n
4218```
4220---
4221### `++gth:rs`
4223Greater than
4225Test whether `a` is greater than `b`.
4227#### Accepts
4229`a` is a `@rs`, a single-precision float.
4231`b` is a `@rs`.
4233#### Produces
4235A `@rs`.
4237#### Source
4239```
4240 ++ gth ~/ %gth
4241 |= [a=@rs b=@rs]
4242 ~_ leaf+"rs-fail"
4243 (gth:ma a b)
4244```
4246#### Examples
4248```
4249 > (gth:rs .9.9e1 .9.2e2)
4250 %.n
4252 > (gth:rs .9.9e1 .9.9e1)
4253 %.n
4255 > (gth:rs .9.9e1 .1.9e1)
4256 %.y
4257```
4259---
4260### `++sun:rs`
4262Unsigned integer to `@rs`
4264Converts `a` from an unsigned integer to `@rs`.
4266#### Accepts
4268`a` is an unsigned integer.
4270#### Produces
4272A `@rs`.
4274#### Source
4276```
4277 ++ sun |= [a=@u] ^- @rs (sun:ma a)
4278```
4280#### Examples
4282```
4283 > (sun:rs 343)
4284 .3.43e2
4285```
4287---
4288### `++san:rs`
4290Signed integer to `@rs`'
4292Converts `a` from an unsigned integer to `@rs`.
4294#### Accepts
4296`a` is a signed integer.
4298#### Produces
4300A `@rs`.
4302#### Source
4304```
4305 ++ san |= [a=@s] ^- @rs (san:ma a)
4306```
4308#### Examples
4310```
4311 > (san:rs -343)
4312 .-3.43e2'
4313```
4315### `++sig:rs`
4317Get sign
4319Produces the sign of `a`.
4321#### Accepts
4323`a` is a `@rs`.
4325#### Produces
4327A `flag`.
4329#### Source
4331```
4332 ++ sig |= [a=@rs] ^- ? (sig:ma a)
4333```
4335#### Examples
4337```
4338 > (sig:rs .3.43e2)
4339 %.y
4341 > (sig:rs .-3.43e2)
4342 %.n
4343```
4345---
4346### `++exp:rs`
4348Get exponent
4350Produces the exponent of `a`.
4352#### Accepts
4354`a` is a `@rs`.
4356#### Produces
4358A signed integer.
4360#### Source
4362```
4363 ++ exp |= [a=@rs] ^- @s (exp:ma a)
4364```
4366#### Examples
4368```
4369 > (exp:rs .-3.43e2)
4370 --8
4371```
4373---
4374### `++toi:rs`
4376Round to integer
4378Rounds `a` to the nearest integer.
4380#### Accepts
4382`a` is a `@rs`.
4384#### Produces
4386A `unit` of `@s`.
4388#### Source
4390```
4391 ++ toi |= [a=@rs] ^- (unit @s) (toi:ma a)
4392```
4394#### Examples
4396```
4397 > (toi:rs .-3.43e2)
4398 [~ u=-343]
4399```
4401---
4402### `++drg:rs`
4404`@rs` to decimal float
4406Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
4407accurate results for rounded floats.
4409#### Accepts
4411`a` is a `@rs`
4413#### Produces
4415A `dn`.
4417#### Source
4419```
4420 ++ drg |= [a=@rs] ^- dn (drg:ma a)
4421```
4423#### Examples
4425```
4426 > (drg:rs .-3.43e2)
4427 [%d s=%.n e=--0 a=343]
4428```
4430---
4431### `++grd:rs`
4433Decimal float to `@rs`
4435Converts `a` from `dn` to `@rs`.
4437#### Accepts
4439`a` is a `dn`.
4441#### Produces
4443A `@rs`.
4445#### Source
4447```
4448 ++ grd |= [a=dn] ^- @rs (grd:ma a)
4449 --
4450```
4452#### Examples
4454```
4455 > (grd:rs [%d s=%.n e=--0 a=343])
4456 .-3.43e2
4457```
4459---
4460### `++rq`
4462Quadruple-precision fp
4464A container core for operations related to quadruple-precision binary floats.
4466`++rq` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
4467down (`$d`), and round to zero (`$z`).
4469#### Source
4471```
4472 ++ rq
4473 ~% %rq +> ~
4474 ^?
4475 |_ r=$?($n $u $d $z)
4476```
4478### `++ma:rq`
4480Initialize `ff`
4482Instantiates the core `ff`, giving values to its samples based on the
4483configuration of the `rq` core.
4485#### Source
4487```
4488 ++ ma
4489 %*(. ff w 15, p 112, b --16.383, r r)
4490```
4492---
4493### `++sea:rq`
4495`@rq` to `fn`
4497Converts `a` from `@rq` to `fn`.
4499#### Accepts
4501`a` is a `@rq`, a quad-precision float.
4503#### Produces
4505An `fn`.
4507#### Source
4509```
4510 ++ sea
4511 |= [a=@rq] (sea:ma a)
4512```
4514#### Examples
4516```
4517 > (sea:rq .~~~1.05102e5)
4518 [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272]
4519```
4521---
4522### `++bit:rq`
4524`fn` to `@rq`
4526Converts `a` from `fn` to `@rq`.
4528#### Accepts
4530`a` is an `fn`.
4532#### Produces
4534A `@rq`, a quad-precision float.
4536#### Source
4538```
4539 ++ bit
4540 |= [a=n] ^- @rq (bit:ma a)
4541```
4543#### Examples
4545```
4546 > (bit:rq [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272])
4547 .~~~1.05102e5
4548```
4550---
4551### `++add:rq`
4553Add
4555Produces the sum of `a` plus `b`.
4557#### Accepts
4559`a` is a `@rq`, a quad-precision float.
4561`b` is a `@rq`.
4563#### Produces
4565A `@rq`.
4567#### Source
4569```
4570 ++ add ~/ %add
4571 |= [a=@rq b=@rq] ^- @rq
4572 ~_ leaf+"rq-fail"
4573 (add:ma a b)
4574```
4576#### Examples
4578```
4579 > (add:rq .~~~-1.821e5 .~~~1.05102e5)
4580 .~~~-7.6998e4
4581```
4583---
4584### `++sub:rq`
4586Subtract
4588Produces the difference of `a` minus `b`.
4590#### Accepts
4592`a` is a `@rq`, a quad-precision float.
4594`b` is a `@rq`.
4596#### Produces
4598A `@rq`.
4600#### Source
4602```
4603 ++ sub ~/ %sub
4604 |= [a=@rq b=@rq] ^- @rq
4605 ~_ leaf+"rq-fail"
4606 (sub:ma a b)
4607```
4609#### Examples
4611```
4612 > (sub:rq .~~~1.821e5 .~~~1.05102e5)
4613 .~~~7.6998e4
4615 > (sub:rq .~~~1.821e5 .~~~-1.05102e5)
4616 .~~~2.87202e5
4617```
4619---
4620### `++mul:rq`
4622Multiply
4624Produces the product of `a` times `b`.
4626#### Accepts
4628`a` is a `@rq`, a quad-precision float.
4630`b` is a `@rq`.
4632#### Produces
4634A `@rq`.
4636#### Source
4638```
4639 ++ mul ~/ %mul
4640 |= [a=@rq b=@rq] ^- @rq
4641 ~_ leaf+"rq-fail"
4642 (mul:ma a b)
4643```
4645#### Examples
4647```
4648 > (mul:rq .~~~1.821e5 .~~~-1.05102e5)
4649 .~~~-1.91390742e10
4650```
4652---
4653### `++div:rq`
4655Divide
4657Produces the product of `a` divided by `b`.
4659#### Accepts
4661`a` is a `@rq`, a quad-precision float.
4663`b` is a `@rq`.
4665#### Produces
4667A `@rq`.
4669#### Source
4671```
4672 ++ div ~/ %div
4673 |= [a=@rq b=@rq] ^- @rq
4674 ~_ leaf+"rq-fail"
4675 (div:ma a b)
4676```
4678#### examples
4680```
4681 > (div:rq .~~~1.821e5 .~~~1.05102e3)
4682 .~~~1.732602614602957127361991208540275e2
4683```
4685---
4686### `++fma:rq`
4688Fused multiply-add
4690Produces the sum of `c` plus the product of `a` multiplied by `b`;
4691`(a * b) + c`.
4693#### Accepts
4695`a` is a `@rq`, a quad-precision float.
4697`b` is a `@rq`.
4699`c` is a `@rq`.
4701#### Produces
4703A `@rq`.
4705#### Source
4707```
4708 ++ fma ~/ %fma
4709 |= [a=@rq b=@rq c=@rq] ^- @rq
4710 ~_ leaf+"rq-fail"
4711 (fma:ma a b c)
4712```
4714#### Examples
4716```
4717 > (fma:rq .~~~1.821e5 .~~~-1.05102e2 .~~~6.2044e7)
4718 .~~~4.29049258e7
4719```
4721---
4722### `++sqt:rq`
4724Square root
4726Produces the square root of `a`.
4728#### Accepts
4730`a` is a `@rq`, a quad-precision float.
4732#### Produces
4734A `@rq`.
4736#### Source
4738```
4739 ++ sqt ~/ %sqt
4740 |= [a=@rq] ^- @rq
4741 ~_ leaf+"rq-fail"
4742 (sqt:ma a)
4743```
4745#### Source
4747```
4748 > (sqt:rq .~~~6.2044e7)
4749 .~~~7.876801381271461258959876570289002e3
4750```
4752---
4753### `++lth:rq`
4755Less than
4757Tests whether `a` is less than `b`.
4759#### Accepts
4761`a` is a `@rq`, a quad-precision float.
4763`b` is a `@rq`.
4765#### Produces
4767A `@rq`.
4769#### Source
4771```
4772 ++ lth ~/ %lth
4773 |= [a=@rq b=@rq]
4774 ~_ leaf+"rq-fail"
4775 (lth:ma a b)
4776```
4779#### Examples
4781```
4782 > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4783 %.n
4785 > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4786 %.y
4787```
4789---
4790### `++lte:rq`
4792Less than or equal
4794Tests whether `a` is less than or equal to `b`.
4796#### Accepts
4798`a` is a `@rq`, a quad-precision float.
4800`b` is a `@rq`.
4802#### Produces
4804A `@rq`.
4806#### Source
4808```
4809 ++ lte ~/ %lte
4810 |= [a=@rq b=@rq]
4811 ~_ leaf+"rq-fail"
4812 (lte:ma a b)
4813```
4815#### Examples
4817```
4818 > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4819 %.n
4821 > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4822 %.y
4824 > (lte:rq .~~~1.2044e7 .~~~1.2044e7)
4825 %.y
4826```
4828---
4829### `++equ:rq`
4831Equals
4833Tests whether `a` is equal to `b`.
4835#### Accepts
4837`a` is a `@rq`, a quad-precision float.
4839`b` is a `@rq`.
4841#### Produces
4843A `@rq`.
4845#### Source
4847```
4848 ++ equ ~/ %equ
4849 |= [a=@rq b=@rq]
4850 ~_ leaf+"rq-fail"
4851 (equ:ma a b)
4852```
4854#### Examples
4856```
4857 > (equ:rq .~~~1.2044e7 .~~~1.2044e7)
4858 %.y
4860 > (equ:rq .~~~2.2044e7 .~~~1.2044e7)
4861 %.n
4862```
4864---
4865### `++gte:rq`
4867Greater than or equal
4869Tests whether `a` is greater than or equal to `b`.
4871#### Accepts
4873`a` is a `@rq`, a quad-precision float.
4875`b` is a `@rq`.
4877#### Produces
4879A `@rq`.
4881#### Source
4883```
4884 ++ gte ~/ %gte
4885 |= [a=@rq b=@rq]
4886 ~_ leaf+"rq-fail"
4887 (gte:ma a b)
4888```
4890#### Examples
4892```
4893 > (gte:rq .~~~1.2044e7 .~~~1.2044e7)
4894 %.y
4896 > (gte:rq .~~~2.2044e7 .~~~1.2044e7)
4897 %.y
4899 > (gte:rq .~~~1.2044e7 .~~~2.2044e7)
4900 %.n
4901```
4903---
4904### `++gth:rq`
4906Tests whether `a` is greater than `b`.
4908#### Accepts
4910`a` is a `@rq`, a quad-precision float.
4912`b` is a `@rq`.
4914#### Produces
4916A `@rq`.
4918#### Source
4920```
4921 ++ gth ~/ %gth
4922 |= [a=@rq b=@rq]
4923 ~_ leaf+"rq-fail"
4924 (gth:ma a b)
4925```
4927#### Examples
4929```
4930 > (gth:rq .~~~1.2044e7 .~~~1.2044e7)
4931 %.n
4933 > (gth:rq .~~~2.2044e7 .~~~1.2044e7)
4934 %.y
4936 > (gth:rq .~~~1.2044e7 .~~~2.2044e7)
4937 %.n
4938```
4940---
4941### `++sun:rq`
4943Unsigned integer to `@rq`
4945Converts `@` from an unsigned integer to `@rq`.
4947#### Accepts
4949`a` is a `@u`, an unsigned integer.
4951#### Produces
4953A `@rq`, a quad-precision float.
4955#### Source
4957```
4958 ++ sun |= [a=@u] ^- @rq (sun:ma a)
4959```
4961#### Examples
4963```
4964 > (sun:rq 205)
4965 .~~~2.05e2
4966```
4968---
4969### `++san:rq`
4971Signed integer to `rq`
4973Converts `@` from a signed integer to `@rq`.
4975#### Accepts
4977`a` is a `@s`, a signed integer.
4979#### Produces
4981A `@rq`, a quad-precision float.
4983#### Source
4985```
4986 ++ san |= [a=@s] ^- @rq (san:ma a)
4987```
4989#### Examples
4991```
4992 > (san:rq -205)
4993 .~~~-2.05e2
4994```
4996---
4997### `++sig:rq`
4999Get sign
5001Produces the sign of `a`.
5003#### Accepts
5005`a` is a `@rq`, a quad-precision float.
5007#### Produces
5009A `flag`.
5011#### Source
5013```
5014 ++ sig |= [a=@rq] ^- ? (sig:ma a)
5015```
5017#### Examples
5019```
5020 > (sig:rq .~~~-2.05e2)
5021 %.n
5022```
5024---
5025### `++exp:rq`
5027Get exponent
5029Gets the exponent of `a`.
5031#### Accepts
5033`a` is a `@rq`, a quad-precision float.
5035#### Produces
5037A `@s`, a signed integer.
5039#### Source
5041```
5042 ++ exp |= [a=@rq] ^- @s (exp:ma a)
5043```
5045#### Examples
5047```
5048 > (exp:rq .~~~-2.05e2)
5049 --7
5050```
5052---
5053### `++toi:rq`
5055Round to integer
5057Rounds `a` to the nearest integer.
5059#### Accepts
5061`a` is a `@rq`, a quad-precision float.
5063#### Produces
5065A `unit` of `@s`.
5067#### Source
5069```
5070 ++ toi |= [a=@rq] ^- (unit @s) (toi:ma a)
5071```
5073#### Examples
5075```
5076 > (toi:rq .~~~-2.085e2)
5077 [~ u=-208]
5079 > (toi:rq .~~~-2.08e2)
5080 [~ u=-208]
5081```
5083---
5084### `++drg:rq`
5086`@rq` to decimal float
5088Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5089accurate results for rounded floats.
5091#### Accepts
5093`a` is a `@rq`, a quad-precision float.
5095#### Produces
5097A `dn`.
5099#### Source
5101```
5102 ++ drg |= [a=@rq] ^- dn (drg:ma a) :: @rq to decimal float
5103```
5105#### Examples
5107```
5108 > (drg:rq .~~~-2.085e2)
5109 [%d s=%.n e=-1 a=2.085]
5111 > (drg:rq .~~~-2.08e2)
5112 [%d s=%.n e=--0 a=208]
5113```
5115---
5116### `++grd:rq`
5118Decimal float to `@rq`
5120Converts `a` from `dn` to `@rq`.
5122#### Accepts
5124`a` is `dn`.
5126`a` is a `@rq`.
5128#### Produces
5130A `@rq`, a quad-precision float.
5132#### Source
5134```
5135 ++ grd |= [a=dn] ^- @rq (grd:ma a)
5136 --
5137```
5139#### Examples
5141```
5142 > (grd:rq [%d s=%.n e=--0 a=343])
5143 .~~~-3.43e2
5144```
5146---
5147### `++rh`
5149Half-precision fp
5151A container core for operations related to half-precision binary floats.
5153`++rh` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
5154down (`$d`), and round to zero (`$z`).
5156#### Source
5158```
5159 ++ rh
5160 ~% %rh +> ~
5161 ^?
5162 |_ r=$?($n $u $d $z)
5163```
5165---
5166### `++ma:rh`
5168Initialize `ff`
5170Instantiates the core `ff`, giving values to its samples based on the
5171configuration of the `rh` core.
5173#### Source
5175```
5176 ++ ma
5177 %*(. ff w 5, p 10, b --15, r r)
5178```
5180---
5181### `++sea:rh`
5183`@rh` to `fn`
5185Converts `a` from `@rh` to `fn`.
5187#### Accepts
5189`a` is a `@rh`, a half-precision float.
5191#### Produces
5193An `fn`.
5195#### Source
5197```
5198 ++ sea
5199 |= [a=@rh] (sea:ma a)
5200```
5202#### Examples
5204```
5205 > (sea:rh .~~1.22e-5)
5206 [%f s=%.y e=-24 a=205]
5207```
5209---
5210### `++bit:rh`
5212`fn` to `@rh`
5214Converts `a` from `fn` to `@rh`.
5216#### Accepts
5218`a` is an `fn`.
5220#### Produces
5222A `@rh`, a half-precision float.
5224#### Source
5226```
5227 ++ bit
5228 |= [a=fn] ^- @rh (bit:ma a)
5229```
5231#### Examples
5233```
5234 > (bit:rh [%f s=%.y e=-24 a=205])
5235 .~~1.22e-5
5236```
5238---
5239### `++add:rh`
5241Produces the sum of `a` plus `b`.
5243#### Accepts
5245`a` is a `@rh`, a half-precision float.
5247`b` is a `@rh`.
5249#### Produces
5251A `@rh`.
5253#### Source
5255```
5256 ++ add ~/ %add
5257 |= [a=@rh b=@rh] ^- @rh
5258 ~_ leaf+"rh-fail"
5259 (add:ma a b)
5260```
5262#### Examples
5264```
5265 > (add:rh .~~1.82e2 .~~1.02e2)
5266 .~~2.84e2
5267```
5269---
5270### `++sub:rh`
5272Subtract
5274Produces the difference of `a` minus `b`.
5276#### Accepts
5278`a` is a `@rh`, a half-precision float.
5280`b` is a `@rh`.
5282#### Produces
5284A `@rh`.
5286#### Source
5288```
5289 ++ sub ~/ %sub
5290 |= [a=@rh b=@rh] ^- @rh
5291 ~_ leaf+"rh-fail"
5292 (sub:ma a b)
5293```
5295#### Examples
5297```
5298 > (sub:rh .~~1.821e2 .~~1.051e2)
5299 .~~7.7e1
5301 > (sub:rh .~~1.821e2 .~~6.051e2)
5302 .~~-4.228e2
5303```
5305---
5306### `++mul:rh`
5308Multiply
5310Produces the product of `a` times `b`.
5312#### Accepts
5314`a` is a `@rh`, a quad-precision float.
5316`b` is a `@rh`.
5318#### Produces
5320A `@rh`.
5322#### Source
5324```
5325 ++ mul ~/ %mul
5326 |= [a=@rh b=@rh] ^- @rh
5327 ~_ leaf+"rh-fail"
5328 (mul:ma a b)
5329```
5331#### Examples
5333```
5334 > (mul:rh .~~1.821e1 .~~-1.05102e2)
5335 .~~-1.913e3
5336```
5338---
5339### `++div:rh`
5341Divide
5343Produces the product of `a` divided by `b`.
5345#### Accepts
5347`a` is a `@rh`, a half-precision float.
5349`b` is a `@rh`.
5351#### Produces
5353A `@rh`.
5355#### Source
5357```
5358 ++ div ~/ %div
5359 |= [a=@rh b=@rh] ^- @rh
5360 ~_ leaf+"rh-fail"
5361 (div:ma a b)
5362```
5364#### examples
5366```
5367 > (div:rh .~~1.821e3 .~~1.05102e2)
5368 .~~1.731e1
5369```
5371---
5372### `++fma:rh`
5374Fused multiply-add
5376Produces the sum of `c` plus the product of `a` multiplied by `b`;
5377`(a * b) + c`.
5379#### Accepts
5381`a` is a `@rh`, a half-precision float.
5383`b` is a `@rh`.
5385`c` is a `@rh`.
5387#### Produces
5389A `@rh`.
5391#### Source
5393```
5394 ++ fma ~/ %fma
5395 |= [a=@rh b=@rh c=@rh] ^- @rh
5396 ~_ leaf+"rh-fail"
5397 (fma:ma a b c)
5398```
5400#### Examples
5402```
5403 > (fma:rh .~~1.821e4 .~~-1.05102e2 .~~6.2044e3)
5404 .~~-6.55e4
5405```
5407---
5408### `++sqt:rh`
5410Square root
5412Produces the square root of `a`.
5414#### Accepts
5416`a` is a `@rh`, a half-precision float.
5418#### Produces
5420A `@rh`.
5422#### Source
5424```
5425 ++ sqt ~/ %sqt
5426 |= [a=@rh] ^- @rh
5427 ~_ leaf+"rh-fail"
5428 (sqt:ma a)
5429```
5431#### Source
5433```
5434 > (sqt:rh .~~6.24e4)
5435 .~~2.498e2
5436```
5438---
5439### `++lth:rh`
5441Less than
5443Tests whether `a` is less than `b`.
5445#### Accepts
5447`a` is a `@rh`, a half-precision float.
5449`b` is a `@rh`.
5451#### Produces
5453A `@rh`.
5455#### Source
5457```
5458 ++ lth ~/ %lth
5459 |= [a=@rh b=@rh]
5460 ~_ leaf+"rh-fail"
5461 (lth:ma a b)
5462```
5464#### Examples
5466```
5467 > (lth:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5468 %.n
5470 > (lth:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5471 %.y
5472```
5474---
5475### `++lte:rh`
5477Less than or equal
5479Tests whether `a` is less than or equal to `b`.
5481#### Accepts
5483`a` is a `@rh`, a half-precision float.
5485`b` is a `@rh`.
5487#### Produces
5489A `@rh`.
5491#### Source
5493```
5494 ++ lte ~/ %lte
5495 |= [a=@rh b=@rh]
5496 ~_ leaf+"rh-fail"
5497 (lte:ma a b)
5498```
5500#### Examples
5502```
5503 > (lte:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5504 %.n
5506 > (lte:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5507 %.y
5509 > (lte:rh .~~1.2e3 .~~1.2e3)
5510 %.y
5511```
5513---
5514### `++equ:rh`
5516Equals
5518Tests whether `a` is equal to `b`.
5520#### Accepts
5522`a` is a `@rh`, a half-precision float.
5524`b` is a `@rh`.
5526#### Produces
5528A `@rh`.
5530#### Source
5532```
5533 ++ equ ~/ %equ
5534 |= [a=@rh b=@rh]
5535 ~_ leaf+"rh-fail"
5536 (equ:ma a b)
5537```
5539#### Examples
5541```
5542 > (equ:rh .~~1.24e4 .~~1.24e4)
5543 %.y
5545 > (equ:rh .~~2.24e4 .~~1.24e4)
5546 %.n
5547```
5549---
5550### `++gte:rh`
5552Greater than or equal
5554Tests whether `a` is greater than or equal to `b`.
5556#### Accepts
5558`a` is a `@rh`, a half-precision float.
5560`b` is a `@rh`.
5562#### Produces
5564A `@rh`.
5566#### Source
5568```
5569 ++ gte ~/ %gte
5570 |= [a=@rh b=@rh]
5571 ~_ leaf+"rh-fail"
5572 (gte:ma a b)
5573```
5575#### Examples
5577```
5578 > (gte:rh .~~1.24e4 .~~1.24e4)
5579 %.y
5581 > (gte:rh .~~2.24e4 .~~1.24e4)
5582 %.y
5584 > (gte:rh .~~1.24e4 .~~2.24e4)
5585 %.n
5586```
5588---
5589### `++gth:rh`
5591Tests whether `a` is greater than `b`.
5593#### Accepts
5595`a` is a `@rh`, a half-precision float.
5597`b` is a `@rh`.
5599#### Produces
5601A `@rh`.
5603#### Source
5605```
5606 ++ gth ~/ %gth
5607 |= [a=@rh b=@rh]
5608 ~_ leaf+"rh-fail"
5609 (gth:ma a b)
5610```
5612#### Examples
5614```
5615 > (gth:rh .~~1.24e4 .~~1.244e4)
5616 %.n
5618 > (gth:rh .~~2.24e4 .~~1.24e4)
5619 %.y
5621 > (gth:rh .~~1.24e4 .~~2.24e4)
5622 %.n
5623```
5625---
5627### `++tos:rh`
5629`@rh` to `@rs`
5631Converts `@` from `@rh` to `@rs`.
5633#### Accepts
5635`a` is a `@rh`, a half-precision float.
5637#### Produces
5639A `@rs`, a single-precision float.
5641#### Source
5643```
5644 ++ tos |= {a/@rh} (bit:rs (sea a))
5645```
5647#### Examples
5649```
5650 > (tos:rh .~~2.5e2)
5651 .2.5e2
5652```
5654---
5655### `++fos:rh`
5657`@rs` to `@rh`
5659Converts `@` from `@rs` to `@rh`.
5661#### Accepts
5663`a` is a `@rs`, a single-precision float.
5665#### Produces
5667A `@rh`, a half-precision float.
5669#### Source
5671```
5672 ++ fos |= {a/@rs} (bit (sea:rs a))
5673```
5675#### Examples
5677```
5678 > (fos:rh .2.5e2)
5679 .~~2.5e2
5680```
5682---
5683### `++sun:rh`
5685Unsigned integer to `@rh`
5687Converts `@` from an unsigned integer to `@rh`.
5689#### Accepts
5691`a` is a `@u`, an unsigned integer.
5693#### Produces
5695A `@rh`, a half-precision float.
5697#### Source
5699```
5700 ++ sun |= [a=@u] ^- @rh (sun:ma a)
5701```
5703#### Examples
5705```
5706 > (sun:rh 205)
5707 .~~2.05e2
5708```
5710---
5711### `++san:rh`
5713Signed integer to `@rh`
5715Converts `@` from a signed integer to `@rh`.
5717#### Accepts
5719`a` is a `@s`, a signed integer.
5721#### Produces
5723A `@rh`, a half-precision float.
5725#### Source
5727```
5728 ++ san |= [a=@s] ^- @rh (san:ma a)
5729```
5731#### Examples
5733```
5734 > (san:rh -205)
5735 .~~-2.05e2
5736```
5738---
5739### `++sig:rh`
5741Get sign
5743Produces the sign of `a`.
5745#### Accepts
5747`a` is a `@rh`, a half-precision float.
5749#### Produces
5751A `flag`.
5753#### Source
5755```
5756 ++ sig |= [a=@rh] ^- ? (sig:ma a)
5757```
5759#### Examples
5761```
5762 > (sig:rh .~~-2.05e2)
5763 %.n
5764```
5766---
5767### `++exp:rh`
5769Get exponent
5771Gets the exponent of `a`.
5773#### Accepts
5775`a` is a `@rh`, a half-precision float.
5777#### Produces
5779A `@s`, a signed integer.
5781#### Source
5783```
5784 ++ exp |= [a=@rh] ^- @s (exp:ma a)
5785```
5787#### Examples
5789```
5790 > (exp:rh .~~-2.05e2)
5791 --7
5792```
5794---
5795### `++toi:rh`
5797Round to integer
5799Rounds `a` to the nearest integer.
5801#### Accepts
5803`a` is a `@rh`, a half-precision float.
5805#### Produces
5807A `unit` of `@s`.
5809#### Source
5811```
5812 ++ toi |= [a=@rh] ^- (unit @s) (toi:ma a)
5813```
5815#### Examples
5817```
5818 > (toi:rh .~~-2.085e2)
5819 [~ u=-208]
5821 > (toi:rh .~~-2.08e2)
5822 [~ u=-208]
5823```
5825---
5826### `++drg:rh`
5828`@rh` to decimal float
5830Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5831accurate results for rounded floats.
5833#### Accepts
5835`a` is a `@rh`, a half-precision float.
5837#### Produces
5839A `dn`.
5841#### Source
5843```
5844 ++ drg |= [a=@rh] ^- dn (drg:ma a)
5845```
5847#### Examples
5849```
5850 > (drg:rh .~~-2.085e2)
5851 [%d s=%.n e=-1 a=2.085]
5853 > (drg:rh .~~-2.08e2)
5854 [%d s=%.n e=--0 a=208]
5855```
5857---
5858### `++grd:rh`
5860Decimal float to `@rh`
5862Converts `a` from `dn` to `@rh`.
5864#### Accepts
5866`a` is `dn`.
5868`a` is a `@rh`.
5870#### Produces
5872A `@rh`, a a half-precision float.
5874#### Source
5876```
5877 ++ grd |= [a=dn] ^- @rh (grd:ma a)
5878 --
5879```
5881#### Examples
5883```
5884 > (grd:rh [%d s=%.n e=--0 a=343])
5885 .~~-3.43e2
5886```
5888---