on b00decd help sign in
5889 lines 84 kB history raw
1+++
2title = "3b: Floating Point"
3weight = 22
4template = "doc.html"
5+++
7### `++fn`
9Float
11A mold for the floating-point arithmetic using the base of two, the formula is
12`(-1)^s * a * 2^e`.
14Produces either a float (`$f`), an infinity of other sign (`$i`),
15or not-a-number (`$n`). `s` refers to sign, the `flag`s `&` or `|`; `e` to
16exponent, a signed decimal; and `a` to the significand, an unsigned integer.
18#### Source
20```hoon
21 ++ fn
22 $% [$f s=? e=@s a=@u]
23 [$i s=?]
24 [$n ~]
25 ==
26```
28### Examples
30```
31 > *fn
32 [%n ~]
34 > (add:fl [%f & --33 2] [%f | --23 2])
35 [%f s=%.y e=-79 a=10.374.452.512.267.829.421.849.019.032.797.184]
37 > (add:fl [%i &] [%i &])
38 [%i s=%.y]
40 > (add:fl [%n ~] [%i |])
41 [%n ~]
43 > (sun:fl 961.193.554.848.514.048.973.893.027.381.506.219.443)
44 [%f s=%.y e=--17 a=7.333.324.850.834.000.007.430.214.137.126.970]
45```
48---
49### `++dn`
51Decimal float
53A mold for the floating-point arithmetic using the base of 10; the formula is
54`(-1)^s * a *10^e`.
56Valid values are a float (`$d`), an infinity (`$i`), or a not-a-number (`$n`).
57`s` refers to sign, the `flag`s `&` or `|`; `e` to exponent, a signed decimal;
58and `a` to the significand, an unsigned integer.
60```hoon
61 ++ dn
62 $% [$d s=? e=@s a=@u]
63 [$i s=?]
64 [$n ~]
65 ==
66```
68#### Examples
70```
71 > `dn`[%d & --0 17.163.091.968]
72 [%d s=%.y e=--0 a=17.163.091.968]
74 > `dn`[%i s=%.y]
75 [%i s=%.y]
77 > `dn`[%n ~]
78 [%n ~]
79```
81---
82### `++rn`
84Parsed decimal float
86A mold for the floating-point arithmetic using the base of 10; the formula is
87`(-1)^s * a *10^e`.
89Produces either a parsed float (`$d`), infinity of either sign (`$i`), or
90not-a-number (`$n`).
92#### Source
94```hoon
95 $% [$d a=? b=[c=@ [d=@ e=@] f=? i=@]]
96 [$i a=?]
97 [$n ~]
98 ==
99```
101#### Examples
103```
104 > `rn`[%d | [2 [3 4] | 17.163]]
105 [%d a=%.n b=[c=2 [d=3 e=4] f=%.n i=17.163]]
106```
108---
109### `++fl`
111Arbitrary-precision floating-point
113Container arm for floating-point arithmetic functions.
115- Precision (`p`): number of bits in the significand; must be at least 2.
116 Default is 113.
117- Minimum exponent (`v`): minimum value of e. Default is -16.494.
118- Width (`w`): Max value of `e` minus min value of `e`. 0 is for fixed-point.
119 Default is 32.765.
120- Rounding mode (`r`): Possible modes are nearest (`$n`), up (`$u`),
121 down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%n`.
122- Behavior (`d`): return denormals (`$d`), flush denormals to zero (`$z`),
123 infinite exponent range (`$i`). Default value is `%d`.
125#### Source
127```hoon
128 ++ fl
129 =+ ^- [[p=@u v=@s w=@u] r=$?($n $u $d $z $a) d=$?($d $f $i)]
130 [[113 -16.494 32.765] %n %d]
131 =>
132 ~% %cofl +> ~
133 |%
134```
136---
137### `++rou:fl`
139Round
141Rounds `a` to a the nearest float that can be represented with a 113-bit
142significand. There is no term to sign the significand, meaning that a positive
143sign will always be produced.
145#### Accepts
147`a` is a cell of a signed integer and an unsigned integer.
149#### Produces
151An `fn`.
153#### Source
155```hoon
156 ++ rou
157 |= [a=[e=@s a=@u]] ^- fn (rau a &)
158```
160#### Examples
162```
163 > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
164 > (^rou:fl [--12 a])
165 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
167 > (^rou:fl [--12 (add a 1)])
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 300)])
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 1.000)])
174 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
175```
177---
178### `++rau:fl`
180Various roundings
182Rounds `a` based on what the state of of `r` in the core contained in `fl`. `t`
183is a sticky bit that represents a value less than ULP(a) = 2^(e.a) when passed
184to `lug:fl`.
186#### Accepts
188`a` is a cell of a signed integer and an unsigned integer.
190`t` is a `flag`.
192#### Produces
194An `fn`.
196#### Source
198```hoon
199 ++ rau
200 |= [a=[e=@s a=@u] t=?] ^- fn
201 ?- r
202 $z (lug %fl a t) $d (lug %fl a t)
203 $a (lug %ce a t) $u (lug %ce a t)
204 $n (lug %ne a t)
205 ==
206```
208#### Examples
210```
211 > (rau:fl [-18 342.602.577] &)
212 [%f s=%.y e=-102 a=6.626.897.619.228.945.634.459.505.846.648.832]
213```
216#### Discussion
218See `lug:fl` for possible rounding operations.
220---
221### `++add:fl`
223Add
225Produces the sum of `a` and `b`. `e` is used to choose between an exact result
226(any-sized significand) or a rounded result (113-bit significand).
228There is no term to sign the significands, so a positive sign will always be
229produced.
231#### Accepts
233`a` is an `fn`.
235`b` is an `fn`
237`e` is a `flag`.
239#### Produces
241An `fn`.
243#### Source
245```hoon
246 ++ add
247 |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
248 =+ q=(dif:si e.a e.b)
249 |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp
250 ?: e
251 [%f & e.b (^add (lsh 0 (abs:si q) a.a) a.b)]
252 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
253 =+ ^= w %+ dif:si e.a %- sun:si :: expanded exp of a
254 ?: (gth prc ma) (^sub prc ma) 0
255 =+ ^= x %+ sum:si e.b (sun:si mb) :: highest exp for b
256 ?: =((cmp:si w x) --1) :: don't need to add
257 ?- r
258 $z (lug %fl a &) $d (lug %fl a &)
259 $a (lug %lg a &) $u (lug %lg a &)
260 $n (lug %na a &)
261 ==
262 (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)])
263```
265#### Examples
267```
268 > (^add:fl [--33 2.718] [--23 11] %.y)
269 [%f s=%.y e=--23 a=2.783.243]
271 > (^add:fl [--33 2.718] [--23 11] %.n)
272 [%f s=%.y e=-68 a=6.890.975.897.521.519.304.902.126.405.156.864]
273```
275---
276### `++sub:fl`
278Subtract
280Produces the difference of `a` minus `b.` `e` is used to choose between an exact
281result (any-sized significand) or a rounded result (113-bit significand).
283#### Accepts
285`a` is a cell of a signed integer and an unsigned integer.
287`b` is a cell of a signed integer and an unsigned integer.
289`e` is a `flag`.
291#### Produces
293An `fn`.
295#### Source
297```hoon
298 ++ sub
299 |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
300 =+ q=(dif:si e.a e.b)
301 |- ?. (syn:si q)
302 (fli $(b a, a b, q +(q), r swr))
303 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
304 =+ ^= w %+ dif:si e.a %- sun:si
305 ?: (gth prc ma) (^sub prc ma) 0
306 =+ ^= x %+ sum:si e.b (sun:si +(mb))
307 ?: &(!e =((cmp:si w x) --1))
308 ?- r
309 $z (lug %sm a &) $d (lug %sm a &)
310 $a (lug %ce a &) $u (lug %ce a &)
311 $n (lug %nt a &)
312 ==
313 =+ j=(lsh 0 (abs:si q) a.a)
314 |- ?. (gte j a.b)
315 (fli $(a.b j, j a.b, r swr))
316 =+ i=(^sub j a.b)
317 ?~ i [%f & zer]
318 ?: e [%f & e.b i] (rou [e.b i])
319```
321#### Examples
323```
324 > (^sub:fl [--33 2.718] [--23 11] %.y)
325 [%f s=%.y e=--23 a=2.783.221]
327 > (^sub:fl [--33 2.718] [--63 11] %.y)
328 [%f s=%.n e=--33 a=11.811.157.346]
329```
331---
332### `++mul:fl`
334Multiply
336Produces the product of `a` multiplied by `b`. There is no term to sign the
337significands, so a positive sign will always be produced.
339#### Accepts
341`a` is a cell of a signed integer and an unsigned integer.
343`b` is a cell of a signed integer and an unsigned integer.
345#### Produces
347An `fn`.
349#### Source
351```hoon
352 ++ mul
353 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
354 (rou (sum:si e.a e.b) (^mul a.a a.b))
355```
357#### Examples
359```
360 > (^mul:fl [--3 2.718] [--23 11])
361 [%f s=%.y e=-72 a=9.475.054.411.405.900.661.487.108.108.582.912]
362```
364---
365### `++div:fl`
367Divide
369Produces the quotient of `a` divided by `b`. There is no term to sign the
370significands, so a positive sign will always be produced.
372#### Accepts
374`a` is a cell of a signed integer and an unsigned integer.
376`b` is a cell of a signed integer and an unsigned integer.
378#### Produces
380An `fn`.
382#### Source
384```hoon
385 ++ div
386 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
387 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
388 =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc))))
389 =. a ?: (syn:si v) a
390 a(e (sum:si v e.a), a (lsh 0 (abs:si v) a.a))
391 =+ [j=(dif:si e.a e.b) q=(dvr a.a a.b)]
392 (rau [j p.q] =(q.q 0))
393```
395#### Examples
397```
398 > (^div:fl [--13 2.718] [--23 11])
399 [%f s=%.y e=-115 a=10.023.198.055.040.952.765.870.659.817.343.907]
400```
402---
403### `++sqt:fl`
405Square root
407Produces the square root of `a`.
409#### Accepts
411`a` is a cell of a signed integer and an unsigned integer.
413#### Produces
415An `fn`.
417#### Source
419```hoon
420 ++ sqt
421 |= [a=[e=@s a=@u]] ^- fn
422 =. a
423 =+ [w=(met 0 a.a) x=(^mul +(prc) 2)]
424 =+ ?:((^lth w x) (^sub x w) 0)
425 =+ ?: =((dis - 1) (dis (abs:si e.a) 1)) -
426 (^add - 1)
427 a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
428 =+ [y=(^sqt a.a) z=(fra:si e.a --2)]
429 (rau [z p.y] =(q.y 0))
430```
432#### Examples
434```
435 > (^sqt:fl [-18 342.602.577])
436 [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
437```
439---
440### `++lth:fl`
442Less than
444Tests if `a` is less than `b`.
446#### Accepts
448`a` is a cell of a signed integer and an unsigned integer.
450`b` is a cell of a signed integer and an unsigned integer.
452#### Produces
454An `flag`.
456#### Source
458```hoon
459 ++ lth
460 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
461 ?: =(e.a e.b) (^lth a.a a.b)
462 =+ c=(cmp:si (ibl a) (ibl b))
463 ?: =(c -1) & ?: =(c --1) |
464 ?: =((cmp:si e.a e.b) -1)
465 (^lth (rsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
466 (^lth (lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
467```
469#### Examples
471```
472 > (^lth:fl [-4 684] [--0 35])
473 %.n
475 > (^lth:fl [-4 684] [--0 90])
476 %.y
477```
479---
480### `++equ:fl`
482Equals
484Tests if `a` is equal to `b`.
486#### Accepts
488`a` is a cell of a signed integer and an unsigned integer.
490`b` is a cell of a signed integer and an unsigned integer.
492#### Produces
494A `flag`.
496#### Source
498```hoon
499 ++ equ
500 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
501 ?. =((ibl a) (ibl b)) |
502 ?: =((cmp:si e.a e.b) -1)
503 =((lsh 0 (abs:si (dif:si e.a e.b)) a.b) a.a)
504 =((lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
505```
507#### Examples
509```
510 > (^equ:fl [-4 480] [-0 50])
511 %.n
513 > (^equ:fl [-4 480] [-0 30])
514 %.y
515```
517---
518### `++ibl:fl`
520Integer binary logarithm
522Produces the lowest power to which the number 2 must be raised to obtain `a` or
523greater.
525#### Accepts
527`a` is a cell of a signed integer and an unsigned integer.
529#### Produces
531A signed integer.
533#### Source
535```hoon
536 ++ ibl
537 |= [a=[e=@s a=@u]] ^- @s
538 (sum:si (sun:si (dec (met 0 a.a))) e.a)
539```
541#### Examples
543```
544 > (ibl:fl [-18 342.602.577])
545 --10
546```
548---
549### `++uni:fl`
551Change representation to odd
553Produces another representation of the floating point `a` where the significand
554is odd. Every floating-point number has a unique representation of this kind. If
555the significand of `a` is already odd, nothing changes.
557#### Accepts
559`a` is a cell of a signed integer and an unsigned integer.
561#### Produces
563A cell of a signed integer and an unsigned integer.
565#### Source
567```hoon
568 ++ uni
569 |= [a=[e=@s a=@u]]
570 |- ?: =((end 0 1 a.a) 1) a
571 $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1))
572```
574#### Examples
576```
577 > (uni:fl [-8 342.602.578])
578 [e=-7 a=171.301.289]
580 > (uni:fl [-8 342.602.577])
581 [e=-8 a=342.602.577]
582```
584---
585### `++xpd:fl`
587Expand
589Produces the fully precise form of `a`, or the denormalized form of `a`.
591#### Accepts
593`a` is a cell of a signed integer and an unsigned integer.
595#### Produces
597A cell of a signed integer and an unsigned integer.
599#### Sources
601```hoon
602 ++ xpd
603 |= [a=[e=@s a=@u]]
604 =+ ma=(met 0 a.a)
605 ?: (gte ma prc) a
606 =+ ?: =(den %i) (^sub prc ma)
607 =+ ^= q
608 =+ w=(dif:si e.a emn)
609 ?: (syn:si w) (abs:si w) 0
610 (min q (^sub prc ma))
611 a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
612```
614#### Examples
616```
617 > (xpd:fl [--3 12])
618 [e=-106 a=7.788.445.287.802.241.442.795.744.493.830.144]
620 > (xpd:fl [-8 342.602.577])
621 [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
623 > (xpd:fl [-92 6.626.897.619.228.945.634.459.505.846.648.832])
624 [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
625```
627---
628### `++lug:fl`
630Central rounding mechanism
632Performs various rounding operations on `a`. An operation is chosen based on the
633value selected for `t`. `s` is a sticky bit that represents a value less than
634ULP(a) = 2^(e.a)
636Possible rounding operations:
637- Floor (`$fl`)
638- Ceiling (`$ce`)
639- Smaller (`$sm`)
640- Larger (`$lg`)
641- Nearest (`$ne`) -- Rounds ties away from 0 if the number is even, rounds
642 toward 0 if the number is odd.
644#### Accepts
646`t` is one of the following: `$fl`, `$ce`, `$sm`, `$lg`, `$ne`, `$na`, or `$nt`.
648`a` is a cell of a signed integer and an unsigned integer.
650`s` is a flag.
652#### Produces
654An `fn`.
656#### Source
658```hoon
659 ::
660 :: central rounding mechanism
661 :: can perform: floor, ceiling, smaller, larger,
662 :: nearest (round ties to: even, away from 0, toward 0)
663 :: s is sticky bit: represents a value less than ulp(a) = 2^(e.a)
664 ::
665 ++ lug
666 ~/ %lug
667 |= [t=$?($fl $ce $sm $lg $ne $na $nt) a=[e=@s a=@u] s=?] ^- fn
668 ?< =(a.a 0)
669 =-
670 ?. =(den %f) - :: flush denormals
671 ?. ?=([$f *] -) -
672 ?: =((met 0 ->+>) prc) - [%f & zer]
673 ::
674 =+ m=(met 0 a.a)
675 ?> |(s (gth m prc)) :: require precision
676 =+ ^= q %+ max
677 ?: (gth m prc) (^sub m prc) 0 :: reduce precision
678 %- abs:si ?: =(den %i) --0 :: enforce min. exp
679 ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0
680 =^ b a :- (end 0 q a.a)
681 a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a))
682 ::
683 ?~ a.a
684 ?< =(den %i)
685 ?- t
686 $fl [%f & zer]
687 $sm [%f & zer]
688 $ce [%f & spd]
689 $lg [%f & spd]
690 $ne ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
691 [%f & ?:((^lth b (bex (dec q))) zer spd)]
692 $nt ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
693 [%f & ?:((^lth b (bex (dec q))) zer spd)]
694 $na [%f & ?:((^lth b (bex (dec q))) zer spd)]
695 ==
696 ::
697 =. a (xpd a)
698 ::
699 =. a
700 ?- t
701 $fl a
702 $lg a(a +(a.a))
703 $sm ?. &(=(b 0) s) a
704 ?: &(=(e.a emn) !=(den %i)) a(a (dec a.a))
705 =+ y=(dec (^mul a.a 2))
706 ?. (lte (met 0 y) prc) a(a (dec a.a))
707 [(dif:si e.a --1) y]
708 $ce ?: &(=(b 0) s) a a(a +(a.a))
709 $ne ?~ b a
710 =+ y=(bex (dec q))
711 ?: &(=(b y) s) :: round halfs to even
712 ?~ (dis a.a 1) a a(a +(a.a))
713 ?: (^lth b y) a a(a +(a.a))
714 $na ?~ b a
715 =+ y=(bex (dec q))
716 ?: (^lth b y) a a(a +(a.a))
717 $nt ?~ b a
718 =+ y=(bex (dec q))
719 ?: =(b y) ?: s a a(a +(a.a))
720 ?: (^lth b y) a a(a +(a.a))
721 ==
722 ::
723 =. a ?. =((met 0 a.a) +(prc)) a
724 a(a (rsh 0 1 a.a), e (sum:si e.a --1))
725 ?~ a.a [%f & zer]
726 ::
727 ?: =(den %i) [%f & a]
728 ?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp
729 ::
730```
732---
733### `++drg:fl`
735Get printable decimal
737Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
738accurate results for rounded floats.
740#### Accepts
742`a` is a cell of a signed integer and an unsigned integer.
744#### Produces
746A cell of a signed integer and an unsigned integer.
748#### Source
750```hoon
751 ++ drg
752 ~/ %drg
753 |= [a=[e=@s a=@u]] ^- [@s @u]
754 ?< =(a.a 0)
755 =. a (xpd a)
756 =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a)
757 =+ s=(lsh 0 ?.((syn:si e.a) (abs:si e.a) 0) 1)
758 =+ mn=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) 1)
759 =+ mp=mn
760 => ?.
761 ?& =(a.a (bex (dec prc))) :: if next smallest
762 |(!=(e.a emn) =(den %i)) :: float is half ULP,
763 == :: tighten lower bound
764 .
765 %= .
766 mp (lsh 0 1 mp)
767 r (lsh 0 1 r)
768 s (lsh 0 1 s)
769 ==
770 =+ [k=--0 q=(^div (^add s 9) 10)]
771 |- ?: (^lth r q)
772 %= $
773 k (dif:si k --1)
774 r (^mul r 10)
775 mn (^mul mn 10)
776 mp (^mul mp 10)
777 ==
778 |- ?: (gte (^add (^mul r 2) mp) (^mul s 2))
779 $(s (^mul s 10), k (sum:si k --1))
780 =+ [u=0 o=0]
781 |- :: r/s+o = a*10^-k
782 =+ v=(dvr (^mul r 10) s)
783 => %= .
784 k (dif:si k --1)
785 u p.v
786 r q.v
787 mn (^mul mn 10)
788 mp (^mul mp 10)
789 ==
790 =+ l=(^lth (^mul r 2) mn) :: in lower bound
791 =+ ^= h :: in upper bound
792 ?| (^lth (^mul s 2) mp)
793 (gth (^mul r 2) (^sub (^mul s 2) mp))
794 ==
795 ?: &(!l !h)
796 $(o (^add (^mul o 10) u))
797 =+ q=&(h |(!l (gth (^mul r 2) s)))
798 =. o (^add (^mul o 10) ?:(q +(u) u))
799 [k o]
800```
802#### Examples
804```
805 > (sun:fl 218.116)
806 [%f s=%.y e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488]
807 > (^drg:fl [e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488])
808 [--0 218.116]
810 > (sun:fl 102.057.673.128.349)
811 [%f s=%.y e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936]
812 > (^drg:fl [e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936])
813 [--0 102.057.673.128.349]
814```
816---
817### `++toj:fl`
819Round to integer
821Rounds float `a` to the nearest decimal float with an exponent of 0.
823#### Accepts
825`a` is a cell of a signed integer and an unsigned integer.
827#### Produces
829An `fn`.
831#### Source
833```hoon
834 ++ toj
835 |= [a=[e=@s a=@u]] ^- fn
836 ?. =((cmp:si e.a --0) -1) [%f & a]
837 =+ x=(abs:si e.a)
838 =+ y=(rsh 0 x a.a)
839 ?: |(=(r %d) =(r %z)) [%f & --0 y]
840 =+ z=(end 0 x a.a)
841 ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))]
842 =+ i=(bex (dec x))
843 ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y]
844 ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)]
845```
847#### Examples
849```
850 > (^toj:fl [-11 7.530.107.827.833.587])
851 [%f s=%.y e=--0 a=3.676.810.462.809]
853 > (^toj:fl [-11 7.530.107.827.833.589])
854 [%f s=%.y e=--0 a=3.676.810.462.809]
855```
857---
858### `++ned:fl`
860Require float
862Produces `a` if `a` is a is of floating-point representation. If `a` is another
863case of `fn`, such as infinity or not-a-number, a crash is produced.
865#### Accepts
867`a` is an `fn`.
869#### Produces
871A cell of a signed integer and an unsigned integer.
873#### Source
875```hoon
876 ++ ned
877 |= [a=fn] ^- [$f s=? e=@s a=@u]
878 ?: ?=([$f *] a) a
879 ~_ leaf+"need-float"
880 !!
881```
883#### Examples
886```
887 > (ned:fl [%f s=%.y e=-11 a=7.530.107.827.833.587])
888 [%f s=%.y e=-11 a=7.530.107.827.833.587]
890 > (ned:fl [%n ~])
891 ! need-float
892 ! exit
894 > (ned:fl [%i |])
895 ! need-float
896 ! exit
897```
899---
900### `++shf:fl`
902Shift power
904Multiplies `a` by 2 to the `b` power without rounding. This results in shifting
905the exponent term by `b`.
907#### Accepts
909`a` is an `fn`.
911`b` is a signed integer.
913#### Produces
915An `fn`.
917#### Source
919```hoon
920 ++ shf
921 |= [a=fn b=@s]
922 ?: |(?=([$n *] a) ?=([$i *] a)) a
923 a(e (sum:si e.a b))
924```
926#### Examples
928```
929 > (shf:fl [[%f & -2 7] --2])
930 [%f s=%.y e=--0 a=7]
932 > (shf:fl [[%f & -2 7] -2])
933 [%f s=%.y e=-4 a=7]
935 > (shf:fl [%f & -11 7.530.107.827.833.587] --5)
936 [%f s=%.y e=-6 a=7.530.107.827.833.587]
937```
939---
940### `++fli:fl`
942Flip sign
944Produces `a` with its signed changed from positive to negative, or vice versa.
946#### Accepts
948`a` is an `fn`.
950#### Produces
952An `fn`.
954#### Source
956```hoon
957 ++ fli
958 |= [a=fn] ^- fn
959 ?-(-.a $f a(s !s.a), $i a(s !s.a), $n a)
960```
962#### Examples
964```
965 > (fli:fl [%f %.y -2 7])
966 [%f s=%.n e=-2 a=7]
968 > (fli:fl [%f %.n --2 30.617])
969 [%f s=%.y e=--2 a=30.617]
971 > (fli:fl [%f | --2 30.617])
972 [%f s=%.y e=--2 a=30.617]
973```
975---
976### `++swr:fl`
978Switch rounding
980Switches the rounding mode of `r:fl`.
982#### Source
984```hoon
985 ++ swr ?+(r r $d %u, $u %d)
986```
988#### Examples
990```
991 > r:fl
992 %n
993 > swr:fl
994 %n
996 > =new-fl fl :: new fl core with changed state
997 > =new-fl new-fl(r %u)
998 > swr:new-fl
999 %d
1000```
1002---
1003### `++prc:fl`
1005Force precision of 2 or greater
1007Produces `p`, the core's precision, if `p` is greater than or equal to 2.
1008Otherwise, a crash is produced.
1010#### Source
1012```hoon
1013 ++ prc ?>((gth p 1) p)
1014```
1016#### Examples
1018```
1019 > prc:fl
1020 113
1022 > =new-fl fl
1023 > =new-fl new-fl(p 1)
1024 > prc:new-fl
1025 ! exit
1027 > =new-fl new-fl(p 2)
1028 > prc:new-fl
1030```
1032---
1033### `++den:fl`
1035Behavior
1037Produces `d:fl`. Denormalizes if `d:fl` is `%d`. Flushes denormals to zero if
1038`d:fl` is `%f`.
1040- Denormalizes if `d:fl` is `%d`.
1041- Flushes denormals to zero if `d:fl` is `%f`.
1042- Infinite exponent range if `$d` is `$i`.
1044The default value of `d` is `%d`.
1046#### Source
1048```hoon
1049 ++ den d
1050```
1052#### Examples
1054```
1055 > den:fl
1056 %d
1058 > =new-fl fl
1059 > =new-fl new-fl(d %f)
1060 > den:new-fl
1061 %f
1062```
1064---
1065### `++emn:fl`
1067Minimum exponent
1069Produces `v:fl`, the minimum exponent. The default minimum exponent is -16.494.
1071#### Source
1073```hoon
1074 ++ emn v
1075```
1077#### Examples
1079```
1080 > emn:fl
1081 -16.494
1082```
1084---
1085### `++emx:fl`
1087Maximum exponent
1089Returns the maximum exponent of `fl`. The default maximum exponent is --16.271.
1091#### Source
1093```hoon
1094 ++ emx (sum:si emn (sun:si w))
1095```
1097#### Examples
1099```
1100 > emx:fl
1101 --16.271
1103 > `@u`emx:fl
1104 32.542
1105```
1107---
1108### `++spd:fl`
1110Smallest denormal
1112Produces the smallest possible denormalized float.
1114#### Source
1116```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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:ff`
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```hoon
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```hoon
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```hoon
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```hoon
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:ff`
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```hoon
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:ff`
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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### `++mul: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```hoon
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```hoon
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```hoon
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:rd`
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
3570 ++ gth ~/ %gth
3571 |= [a=@rd b=@rd]
3572 ~_ leaf+"rd-fail"
3573 (gth:ma a b)
3574```
3576#### Examples
3578```
3579 > (gth:rd .~7.94099e2 .~1.2246e3)
3580 %.n
3582 > (gth:rd .~7.94099e2 .~1.2246e2)
3583 %.y
3585 > (gth:rd .~1.2246e2 .~1.2246e2)
3586 %.n
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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### `++sqt:rq`
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```hoon
4740 ++ sqt ~/ %sqt
4741 |= [a=@rq] ^- @rq
4742 ~_ leaf+"rq-fail"
4743 (sqt:ma a)
4744```
4746#### Examples
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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```hoon
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### `++sqt:rh`
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```hoon
5426 ++ sqt ~/ %sqt
5427 |= [a=@rh] ^- @rh
5428 ~_ leaf+"rh-fail"
5429 (sqt:ma a)
5430```
5432#### Source
5434```hoon
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```hoon
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```hoon
5495 ++ lte ~/ %lte
5496 |= [a=@rh b=@rh]
5497 ~_ leaf+"rh-fail"
5498 (lte:ma a b)
5499```
5501#### Examples
5503```
5504 > (lte:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5505 %.n
5507 > (lte: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```hoon
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```hoon
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```hoon
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---
5628### `++tos:rh`
5630`@rh` to `@rs`
5632Converts `@` from `@rh` to `@rs`.
5634#### Accepts
5636`a` is a `@rh`, a half-precision float.
5638#### Produces
5640A `@rs`, a single-precision float.
5642#### Source
5644```hoon
5645 ++ tos |= {a/@rh} (bit:rs (sea a))
5646```
5648#### Examples
5650```
5651 > (tos:rh .~~2.5e2)
5652 .2.5e2
5653```
5655---
5656### `++fos:rh`
5658`@rs` to `@rh`
5660Converts `@` from `@rs` to `@rh`.
5662#### Accepts
5664`a` is a `@rs`, a single-precision float.
5666#### Produces
5668A `@rh`, a half-precision float.
5670#### Source
5672```hoon
5673 ++ fos |= {a/@rs} (bit (sea:rs a))
5674```
5676#### Examples
5678```
5679 > (fos:rh .2.5e2)
5680 .~~2.5e2
5681```
5683---
5684### `++sun:rh`
5686Unsigned integer to `@rh`
5688Converts `@` from an unsigned integer to `@rh`.
5690#### Accepts
5692`a` is a `@u`, an unsigned integer.
5694#### Produces
5696A `@rh`, a half-precision float.
5698#### Source
5700```hoon
5701 ++ sun |= [a=@u] ^- @rh (sun:ma a)
5702```
5704#### Examples
5706```
5707 > (sun:rh 205)
5708 .~~2.05e2
5709```
5711---
5712### `++san:rh`
5714Signed integer to `@rh`
5716Converts `@` from a signed integer to `@rh`.
5718#### Accepts
5720`a` is a `@s`, a signed integer.
5722#### Produces
5724A `@rh`, a half-precision float.
5726#### Source
5728```hoon
5729 ++ san |= [a=@s] ^- @rh (san:ma a)
5730```
5732#### Examples
5734```
5735 > (san:rh -205)
5736 .~~-2.05e2
5737```
5739---
5740### `++sig:rh`
5742Get sign
5744Produces the sign of `a`.
5746#### Accepts
5748`a` is a `@rh`, a half-precision float.
5750#### Produces
5752A `flag`.
5754#### Source
5756```hoon
5757 ++ sig |= [a=@rh] ^- ? (sig:ma a)
5758```
5760#### Examples
5762```
5763 > (sig:rh .~~-2.05e2)
5764 %.n
5765```
5767---
5768### `++exp:rh`
5770Get exponent
5772Gets the exponent of `a`.
5774#### Accepts
5776`a` is a `@rh`, a half-precision float.
5778#### Produces
5780A `@s`, a signed integer.
5782#### Source
5784```hoon
5785 ++ exp |= [a=@rh] ^- @s (exp:ma a)
5786```
5788#### Examples
5790```
5791 > (exp:rh .~~-2.05e2)
5792 --7
5793```
5795---
5796### `++toi:rh`
5798Round to integer
5800Rounds `a` to the nearest integer.
5802#### Accepts
5804`a` is a `@rh`, a half-precision float.
5806#### Produces
5808A `unit` of `@s`.
5810#### Source
5812```hoon
5813 ++ toi |= [a=@rh] ^- (unit @s) (toi:ma a)
5814```
5816#### Examples
5818```
5819 > (toi:rh .~~-2.085e2)
5820 [~ u=-208]
5822 > (toi:rh .~~-2.08e2)
5823 [~ u=-208]
5824```
5826---
5827### `++drg:rh`
5829`@rh` to decimal float
5831Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5832accurate results for rounded floats.
5834#### Accepts
5836`a` is a `@rh`, a half-precision float.
5838#### Produces
5840A `dn`.
5842#### Source
5844```hoon
5845 ++ drg |= [a=@rh] ^- dn (drg:ma a)
5846```
5848#### Examples
5850```
5851 > (drg:rh .~~-2.085e2)
5852 [%d s=%.n e=-1 a=2.085]
5854 > (drg:rh .~~-2.08e2)
5855 [%d s=%.n e=--0 a=208]
5856```
5858---
5859### `++grd:rh`
5861Decimal float to `@rh`
5863Converts `a` from `dn` to `@rh`.
5865#### Accepts
5867`a` is `dn`.
5869`a` is a `@rh`.
5871#### Produces
5873A `@rh`, a a half-precision float.
5875#### Source
5877```hoon
5878 ++ grd |= [a=dn] ^- @rh (grd:ma a)
5879 --
5880```
5882#### Examples
5884```
5885 > (grd:rh [%d s=%.n e=--0 a=343])
5886 .~~-3.43e2
5887```
5889---