on bbd4189 help sign in
6060 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```
47---
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---
83## `++rn`
85Parsed decimal float
87A mold for the floating-point arithmetic using the base of 10; the formula is
88`(-1)^s * a *10^e`.
90Produces either a parsed float (`$d`), infinity of either sign (`$i`), or
91not-a-number (`$n`).
93#### Source
95```hoon
96 $% [$d a=? b=[c=@ [d=@ e=@] f=? i=@]]
97 [$i a=?]
98 [$n ~]
99 ==
100```
102#### Examples
104```
105 > `rn`[%d | [2 [3 4] | 17.163]]
106 [%d a=%.n b=[c=2 [d=3 e=4] f=%.n i=17.163]]
107```
109---
111## `++fl`
113Arbitrary-precision floating-point
115Container arm for floating-point arithmetic functions.
117- Precision (`p`): number of bits in the significand; must be at least 2.
118 Default is 113.
119- Minimum exponent (`v`): minimum value of e. Default is -16.494.
120- Width (`w`): Max value of `e` minus min value of `e`. 0 is for fixed-point.
121 Default is 32.765.
122- Rounding mode (`r`): Possible modes are nearest (`$n`), up (`$u`),
123 down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%n`.
124- Behavior (`d`): return denormals (`$d`), flush denormals to zero (`$z`),
125 infinite exponent range (`$i`). Default value is `%d`.
127#### Source
129```hoon
130 ++ fl
131 =+ ^- [[p=@u v=@s w=@u] r=$?($n $u $d $z $a) d=$?($d $f $i)]
132 [[113 -16.494 32.765] %n %d]
133 =>
134 ~% %cofl +> ~
135 |%
136```
138---
140### `++rou:fl`
142Round
144Rounds `a` to a the nearest float that can be represented with a 113-bit
145significand. There is no term to sign the significand, meaning that a positive
146sign will always be produced.
148#### Accepts
150`a` is a cell of a signed integer and an unsigned integer.
152#### Produces
154An `fn`.
156#### Source
158```hoon
159 ++ rou
160 |= [a=[e=@s a=@u]] ^- fn (rau a &)
161```
163#### Examples
165```
166 > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
167 > (^rou:fl [--12 a])
168 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
170 > (^rou:fl [--12 (add a 1)])
171 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
173 > (^rou:fl [--12 (add a 300)])
174 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
176 > (^rou:fl [--12 (add a 1.000)])
177 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
178```
180---
182### `++rau:fl`
184Various roundings
186Rounds `a` based on what the state of of `r` in the core contained in `fl`. `t`
187is a sticky bit that represents a value less than ULP(a) = 2^(e.a) when passed
188to `lug:fl`.
190#### Accepts
192`a` is a cell of a signed integer and an unsigned integer.
194`t` is a `flag`.
196#### Produces
198An `fn`.
200#### Source
202```hoon
203 ++ rau
204 |= [a=[e=@s a=@u] t=?] ^- fn
205 ?- r
206 $z (lug %fl a t) $d (lug %fl a t)
207 $a (lug %ce a t) $u (lug %ce a t)
208 $n (lug %ne a t)
209 ==
210```
212#### Examples
214```
215 > (rau:fl [-18 342.602.577] &)
216 [%f s=%.y e=-102 a=6.626.897.619.228.945.634.459.505.846.648.832]
217```
219#### Discussion
221See `lug:fl` for possible rounding operations.
223---
225### `++add:fl`
227Add
229Produces the sum of `a` and `b`. `e` is used to choose between an exact result
230(any-sized significand) or a rounded result (113-bit significand).
232There is no term to sign the significands, so a positive sign will always be
233produced.
235#### Accepts
237`a` is an `fn`.
239`b` is an `fn`
241`e` is a `flag`.
243#### Produces
245An `fn`.
247#### Source
249```hoon
250 ++ add
251 |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
252 =+ q=(dif:si e.a e.b)
253 |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp
254 ?: e
255 [%f & e.b (^add (lsh 0 (abs:si q) a.a) a.b)]
256 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
257 =+ ^= w %+ dif:si e.a %- sun:si :: expanded exp of a
258 ?: (gth prc ma) (^sub prc ma) 0
259 =+ ^= x %+ sum:si e.b (sun:si mb) :: highest exp for b
260 ?: =((cmp:si w x) --1) :: don't need to add
261 ?- r
262 $z (lug %fl a &) $d (lug %fl a &)
263 $a (lug %lg a &) $u (lug %lg a &)
264 $n (lug %na a &)
265 ==
266 (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)])
267```
269#### Examples
271```
272 > (^add:fl [--33 2.718] [--23 11] %.y)
273 [%f s=%.y e=--23 a=2.783.243]
275 > (^add:fl [--33 2.718] [--23 11] %.n)
276 [%f s=%.y e=-68 a=6.890.975.897.521.519.304.902.126.405.156.864]
277```
279---
281### `++sub:fl`
283Subtract
285Produces the difference of `a` minus `b.` `e` is used to choose between an exact
286result (any-sized significand) or a rounded result (113-bit significand).
288#### Accepts
290`a` is a cell of a signed integer and an unsigned integer.
292`b` is a cell of a signed integer and an unsigned integer.
294`e` is a `flag`.
296#### Produces
298An `fn`.
300#### Source
302```hoon
303 ++ sub
304 |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
305 =+ q=(dif:si e.a e.b)
306 |- ?. (syn:si q)
307 (fli $(b a, a b, q +(q), r swr))
308 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
309 =+ ^= w %+ dif:si e.a %- sun:si
310 ?: (gth prc ma) (^sub prc ma) 0
311 =+ ^= x %+ sum:si e.b (sun:si +(mb))
312 ?: &(!e =((cmp:si w x) --1))
313 ?- r
314 $z (lug %sm a &) $d (lug %sm a &)
315 $a (lug %ce a &) $u (lug %ce a &)
316 $n (lug %nt a &)
317 ==
318 =+ j=(lsh 0 (abs:si q) a.a)
319 |- ?. (gte j a.b)
320 (fli $(a.b j, j a.b, r swr))
321 =+ i=(^sub j a.b)
322 ?~ i [%f & zer]
323 ?: e [%f & e.b i] (rou [e.b i])
324```
326#### Examples
328```
329 > (^sub:fl [--33 2.718] [--23 11] %.y)
330 [%f s=%.y e=--23 a=2.783.221]
332 > (^sub:fl [--33 2.718] [--63 11] %.y)
333 [%f s=%.n e=--33 a=11.811.157.346]
334```
336---
338### `++mul:fl`
340Multiply
342Produces the product of `a` multiplied by `b`. There is no term to sign the
343significands, so a positive sign will always be produced.
345#### Accepts
347`a` is a cell of a signed integer and an unsigned integer.
349`b` is a cell of a signed integer and an unsigned integer.
351#### Produces
353An `fn`.
355#### Source
357```hoon
358 ++ mul
359 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
360 (rou (sum:si e.a e.b) (^mul a.a a.b))
361```
363#### Examples
365```
366 > (^mul:fl [--3 2.718] [--23 11])
367 [%f s=%.y e=-72 a=9.475.054.411.405.900.661.487.108.108.582.912]
368```
370---
372### `++div:fl`
374Divide
376Produces the quotient of `a` divided by `b`. There is no term to sign the
377significands, so a positive sign will always be produced.
379#### Accepts
381`a` is a cell of a signed integer and an unsigned integer.
383`b` is a cell of a signed integer and an unsigned integer.
385#### Produces
387An `fn`.
389#### Source
391```hoon
392 ++ div
393 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
394 =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
395 =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc))))
396 =. a ?: (syn:si v) a
397 a(e (sum:si v e.a), a (lsh 0 (abs:si v) a.a))
398 =+ [j=(dif:si e.a e.b) q=(dvr a.a a.b)]
399 (rau [j p.q] =(q.q 0))
400```
402#### Examples
404```
405 > (^div:fl [--13 2.718] [--23 11])
406 [%f s=%.y e=-115 a=10.023.198.055.040.952.765.870.659.817.343.907]
407```
409---
411### `++sqt:fl`
413Square root
415Produces the square root of `a`.
417#### Accepts
419`a` is a cell of a signed integer and an unsigned integer.
421#### Produces
423An `fn`.
425#### Source
427```hoon
428 ++ sqt
429 |= [a=[e=@s a=@u]] ^- fn
430 =. a
431 =+ [w=(met 0 a.a) x=(^mul +(prc) 2)]
432 =+ ?:((^lth w x) (^sub x w) 0)
433 =+ ?: =((dis - 1) (dis (abs:si e.a) 1)) -
434 (^add - 1)
435 a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
436 =+ [y=(^sqt a.a) z=(fra:si e.a --2)]
437 (rau [z p.y] =(q.y 0))
438```
440#### Examples
442```
443 > (^sqt:fl [-18 342.602.577])
444 [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
445```
447---
449### `++lth:fl`
451Less than
453Tests if `a` is less than `b`.
455#### Accepts
457`a` is a cell of a signed integer and an unsigned integer.
459`b` is a cell of a signed integer and an unsigned integer.
461#### Produces
463An `flag`.
465#### Source
467```hoon
468 ++ lth
469 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
470 ?: =(e.a e.b) (^lth a.a a.b)
471 =+ c=(cmp:si (ibl a) (ibl b))
472 ?: =(c -1) & ?: =(c --1) |
473 ?: =((cmp:si e.a e.b) -1)
474 (^lth (rsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
475 (^lth (lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
476```
478#### Examples
480```
481 > (^lth:fl [-4 684] [--0 35])
482 %.n
484 > (^lth:fl [-4 684] [--0 90])
485 %.y
486```
488---
490### `++equ:fl`
492Equals
494Tests if `a` is equal to `b`.
496#### Accepts
498`a` is a cell of a signed integer and an unsigned integer.
500`b` is a cell of a signed integer and an unsigned integer.
502#### Produces
504A `flag`.
506#### Source
508```hoon
509 ++ equ
510 |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
511 ?. =((ibl a) (ibl b)) |
512 ?: =((cmp:si e.a e.b) -1)
513 =((lsh 0 (abs:si (dif:si e.a e.b)) a.b) a.a)
514 =((lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
515```
517#### Examples
519```
520 > (^equ:fl [-4 480] [-0 50])
521 %.n
523 > (^equ:fl [-4 480] [-0 30])
524 %.y
525```
527---
529### `++ibl:fl`
531Integer binary logarithm
533Produces the lowest power to which the number 2 must be raised to obtain `a` or
534greater.
536#### Accepts
538`a` is a cell of a signed integer and an unsigned integer.
540#### Produces
542A signed integer.
544#### Source
546```hoon
547 ++ ibl
548 |= [a=[e=@s a=@u]] ^- @s
549 (sum:si (sun:si (dec (met 0 a.a))) e.a)
550```
552#### Examples
554```
555 > (ibl:fl [-18 342.602.577])
556 --10
557```
559---
561### `++uni:fl`
563Change representation to odd
565Produces another representation of the floating point `a` where the significand
566is odd. Every floating-point number has a unique representation of this kind. If
567the significand of `a` is already odd, nothing changes.
569#### Accepts
571`a` is a cell of a signed integer and an unsigned integer.
573#### Produces
575A cell of a signed integer and an unsigned integer.
577#### Source
579```hoon
580 ++ uni
581 |= [a=[e=@s a=@u]]
582 |- ?: =((end 0 1 a.a) 1) a
583 $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1))
584```
586#### Examples
588```
589 > (uni:fl [-8 342.602.578])
590 [e=-7 a=171.301.289]
592 > (uni:fl [-8 342.602.577])
593 [e=-8 a=342.602.577]
594```
596---
598### `++xpd:fl`
600Expand
602Produces the fully precise form of `a`, or the denormalized form of `a`.
604#### Accepts
606`a` is a cell of a signed integer and an unsigned integer.
608#### Produces
610A cell of a signed integer and an unsigned integer.
612#### Sources
614```hoon
615 ++ xpd
616 |= [a=[e=@s a=@u]]
617 =+ ma=(met 0 a.a)
618 ?: (gte ma prc) a
619 =+ ?: =(den %i) (^sub prc ma)
620 =+ ^= q
621 =+ w=(dif:si e.a emn)
622 ?: (syn:si w) (abs:si w) 0
623 (min q (^sub prc ma))
624 a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
625```
627#### Examples
629```
630 > (xpd:fl [--3 12])
631 [e=-106 a=7.788.445.287.802.241.442.795.744.493.830.144]
633 > (xpd:fl [-8 342.602.577])
634 [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
636 > (xpd:fl [-92 6.626.897.619.228.945.634.459.505.846.648.832])
637 [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
638```
640---
642### `++lug:fl`
644Central rounding mechanism
646Performs various rounding operations on `a`. An operation is chosen based on the
647value selected for `t`. `s` is a sticky bit that represents a value less than
648ULP(a) = 2^(e.a)
650Possible rounding operations:
652- Floor (`$fl`)
653- Ceiling (`$ce`)
654- Smaller (`$sm`)
655- Larger (`$lg`)
656- Nearest (`$ne`) -- Rounds ties away from 0 if the number is even, rounds
657 toward 0 if the number is odd.
659#### Accepts
661`t` is one of the following: `$fl`, `$ce`, `$sm`, `$lg`, `$ne`, `$na`, or `$nt`.
663`a` is a cell of a signed integer and an unsigned integer.
665`s` is a flag.
667#### Produces
669An `fn`.
671#### Source
673```hoon
674 ::
675 :: central rounding mechanism
676 :: can perform: floor, ceiling, smaller, larger,
677 :: nearest (round ties to: even, away from 0, toward 0)
678 :: s is sticky bit: represents a value less than ulp(a) = 2^(e.a)
679 ::
680 ++ lug
681 ~/ %lug
682 |= [t=$?($fl $ce $sm $lg $ne $na $nt) a=[e=@s a=@u] s=?] ^- fn
683 ?< =(a.a 0)
684 =-
685 ?. =(den %f) - :: flush denormals
686 ?. ?=([$f *] -) -
687 ?: =((met 0 ->+>) prc) - [%f & zer]
688 ::
689 =+ m=(met 0 a.a)
690 ?> |(s (gth m prc)) :: require precision
691 =+ ^= q %+ max
692 ?: (gth m prc) (^sub m prc) 0 :: reduce precision
693 %- abs:si ?: =(den %i) --0 :: enforce min. exp
694 ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0
695 =^ b a :- (end 0 q a.a)
696 a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a))
697 ::
698 ?~ a.a
699 ?< =(den %i)
700 ?- t
701 $fl [%f & zer]
702 $sm [%f & zer]
703 $ce [%f & spd]
704 $lg [%f & spd]
705 $ne ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
706 [%f & ?:((^lth b (bex (dec q))) zer spd)]
707 $nt ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
708 [%f & ?:((^lth b (bex (dec q))) zer spd)]
709 $na [%f & ?:((^lth b (bex (dec q))) zer spd)]
710 ==
711 ::
712 =. a (xpd a)
713 ::
714 =. a
715 ?- t
716 $fl a
717 $lg a(a +(a.a))
718 $sm ?. &(=(b 0) s) a
719 ?: &(=(e.a emn) !=(den %i)) a(a (dec a.a))
720 =+ y=(dec (^mul a.a 2))
721 ?. (lte (met 0 y) prc) a(a (dec a.a))
722 [(dif:si e.a --1) y]
723 $ce ?: &(=(b 0) s) a a(a +(a.a))
724 $ne ?~ b a
725 =+ y=(bex (dec q))
726 ?: &(=(b y) s) :: round halfs to even
727 ?~ (dis a.a 1) a a(a +(a.a))
728 ?: (^lth b y) a a(a +(a.a))
729 $na ?~ b a
730 =+ y=(bex (dec q))
731 ?: (^lth b y) a a(a +(a.a))
732 $nt ?~ b a
733 =+ y=(bex (dec q))
734 ?: =(b y) ?: s a a(a +(a.a))
735 ?: (^lth b y) a a(a +(a.a))
736 ==
737 ::
738 =. a ?. =((met 0 a.a) +(prc)) a
739 a(a (rsh 0 1 a.a), e (sum:si e.a --1))
740 ?~ a.a [%f & zer]
741 ::
742 ?: =(den %i) [%f & a]
743 ?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp
744 ::
745```
747---
749### `++drg:fl`
751Get printable decimal
753Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
754accurate results for rounded floats.
756#### Accepts
758`a` is a cell of a signed integer and an unsigned integer.
760#### Produces
762A cell of a signed integer and an unsigned integer.
764#### Source
766```hoon
767 ++ drg
768 ~/ %drg
769 |= [a=[e=@s a=@u]] ^- [@s @u]
770 ?< =(a.a 0)
771 =. a (xpd a)
772 =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a)
773 =+ s=(lsh 0 ?.((syn:si e.a) (abs:si e.a) 0) 1)
774 =+ mn=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) 1)
775 =+ mp=mn
776 => ?.
777 ?& =(a.a (bex (dec prc))) :: if next smallest
778 |(!=(e.a emn) =(den %i)) :: float is half ULP,
779 == :: tighten lower bound
780 .
781 %= .
782 mp (lsh 0 1 mp)
783 r (lsh 0 1 r)
784 s (lsh 0 1 s)
785 ==
786 =+ [k=--0 q=(^div (^add s 9) 10)]
787 |- ?: (^lth r q)
788 %= $
789 k (dif:si k --1)
790 r (^mul r 10)
791 mn (^mul mn 10)
792 mp (^mul mp 10)
793 ==
794 |- ?: (gte (^add (^mul r 2) mp) (^mul s 2))
795 $(s (^mul s 10), k (sum:si k --1))
796 =+ [u=0 o=0]
797 |- :: r/s+o = a*10^-k
798 =+ v=(dvr (^mul r 10) s)
799 => %= .
800 k (dif:si k --1)
801 u p.v
802 r q.v
803 mn (^mul mn 10)
804 mp (^mul mp 10)
805 ==
806 =+ l=(^lth (^mul r 2) mn) :: in lower bound
807 =+ ^= h :: in upper bound
808 ?| (^lth (^mul s 2) mp)
809 (gth (^mul r 2) (^sub (^mul s 2) mp))
810 ==
811 ?: &(!l !h)
812 $(o (^add (^mul o 10) u))
813 =+ q=&(h |(!l (gth (^mul r 2) s)))
814 =. o (^add (^mul o 10) ?:(q +(u) u))
815 [k o]
816```
818#### Examples
820```
821 > (sun:fl 218.116)
822 [%f s=%.y e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488]
823 > (^drg:fl [e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488])
824 [--0 218.116]
826 > (sun:fl 102.057.673.128.349)
827 [%f s=%.y e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936]
828 > (^drg:fl [e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936])
829 [--0 102.057.673.128.349]
830```
832---
834### `++toj:fl`
836Round to integer
838Rounds float `a` to the nearest decimal float with an exponent of 0.
840#### Accepts
842`a` is a cell of a signed integer and an unsigned integer.
844#### Produces
846An `fn`.
848#### Source
850```hoon
851 ++ toj
852 |= [a=[e=@s a=@u]] ^- fn
853 ?. =((cmp:si e.a --0) -1) [%f & a]
854 =+ x=(abs:si e.a)
855 =+ y=(rsh 0 x a.a)
856 ?: |(=(r %d) =(r %z)) [%f & --0 y]
857 =+ z=(end 0 x a.a)
858 ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))]
859 =+ i=(bex (dec x))
860 ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y]
861 ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)]
862```
864#### Examples
866```
867 > (^toj:fl [-11 7.530.107.827.833.587])
868 [%f s=%.y e=--0 a=3.676.810.462.809]
870 > (^toj:fl [-11 7.530.107.827.833.589])
871 [%f s=%.y e=--0 a=3.676.810.462.809]
872```
874---
876### `++ned:fl`
878Require float
880Produces `a` if `a` is a is of floating-point representation. If `a` is another
881case of `fn`, such as infinity or not-a-number, a crash is produced.
883#### Accepts
885`a` is an `fn`.
887#### Produces
889A cell of a signed integer and an unsigned integer.
891#### Source
893```hoon
894 ++ ned
895 |= [a=fn] ^- [$f s=? e=@s a=@u]
896 ?: ?=([$f *] a) a
897 ~_ leaf+"need-float"
898 !!
899```
901#### Examples
903```
904 > (ned:fl [%f s=%.y e=-11 a=7.530.107.827.833.587])
905 [%f s=%.y e=-11 a=7.530.107.827.833.587]
907 > (ned:fl [%n ~])
908 ! need-float
909 ! exit
911 > (ned:fl [%i |])
912 ! need-float
913 ! exit
914```
916---
918### `++shf:fl`
920Shift power
922Multiplies `a` by 2 to the `b` power without rounding. This results in shifting
923the exponent term by `b`.
925#### Accepts
927`a` is an `fn`.
929`b` is a signed integer.
931#### Produces
933An `fn`.
935#### Source
937```hoon
938 ++ shf
939 |= [a=fn b=@s]
940 ?: |(?=([$n *] a) ?=([$i *] a)) a
941 a(e (sum:si e.a b))
942```
944#### Examples
946```
947 > (shf:fl [[%f & -2 7] --2])
948 [%f s=%.y e=--0 a=7]
950 > (shf:fl [[%f & -2 7] -2])
951 [%f s=%.y e=-4 a=7]
953 > (shf:fl [%f & -11 7.530.107.827.833.587] --5)
954 [%f s=%.y e=-6 a=7.530.107.827.833.587]
955```
957---
959### `++fli:fl`
961Flip sign
963Produces `a` with its signed changed from positive to negative, or vice versa.
965#### Accepts
967`a` is an `fn`.
969#### Produces
971An `fn`.
973#### Source
975```hoon
976 ++ fli
977 |= [a=fn] ^- fn
978 ?-(-.a $f a(s !s.a), $i a(s !s.a), $n a)
979```
981#### Examples
983```
984 > (fli:fl [%f %.y -2 7])
985 [%f s=%.n e=-2 a=7]
987 > (fli:fl [%f %.n --2 30.617])
988 [%f s=%.y e=--2 a=30.617]
990 > (fli:fl [%f | --2 30.617])
991 [%f s=%.y e=--2 a=30.617]
992```
994---
996### `++swr:fl`
998Switch rounding
1000Switches the rounding mode of `r:fl`.
1002#### Source
1004```hoon
1005 ++ swr ?+(r r $d %u, $u %d)
1006```
1008#### Examples
1010```
1011 > r:fl
1012 %n
1013 > swr:fl
1014 %n
1016 > =new-fl fl :: new fl core with changed state
1017 > =new-fl new-fl(r %u)
1018 > swr:new-fl
1019 %d
1020```
1022---
1024### `++prc:fl`
1026Force precision of 2 or greater
1028Produces `p`, the core's precision, if `p` is greater than or equal to 2.
1029Otherwise, a crash is produced.
1031#### Source
1033```hoon
1034 ++ prc ?>((gth p 1) p)
1035```
1037#### Examples
1039```
1040 > prc:fl
1041 113
1043 > =new-fl fl
1044 > =new-fl new-fl(p 1)
1045 > prc:new-fl
1046 ! exit
1048 > =new-fl new-fl(p 2)
1049 > prc:new-fl
1051```
1053---
1055### `++den:fl`
1057Behavior
1059Produces `d:fl`. Denormalizes if `d:fl` is `%d`. Flushes denormals to zero if
1060`d:fl` is `%f`.
1062- Denormalizes if `d:fl` is `%d`.
1063- Flushes denormals to zero if `d:fl` is `%f`.
1064- Infinite exponent range if `$d` is `$i`.
1066The default value of `d` is `%d`.
1068#### Source
1070```hoon
1071 ++ den d
1072```
1074#### Examples
1076```
1077 > den:fl
1078 %d
1080 > =new-fl fl
1081 > =new-fl new-fl(d %f)
1082 > den:new-fl
1083 %f
1084```
1086---
1088### `++emn:fl`
1090Minimum exponent
1092Produces `v:fl`, the minimum exponent. The default minimum exponent is -16.494.
1094#### Source
1096```hoon
1097 ++ emn v
1098```
1100#### Examples
1102```
1103 > emn:fl
1104 -16.494
1105```
1107---
1109### `++emx:fl`
1111Maximum exponent
1113Returns the maximum exponent of `fl`. The default maximum exponent is --16.271.
1115#### Source
1117```hoon
1118 ++ emx (sum:si emn (sun:si w))
1119```
1121#### Examples
1123```
1124 > emx:fl
1125 --16.271
1127 > `@u`emx:fl
1128 32.542
1129```
1131---
1133### `++spd:fl`
1135Smallest denormal
1137Produces the smallest possible denormalized float.
1139#### Source
1141```hoon
1142 ++ spd [e=emn a=1]
1143```
1145#### Examples
1147```
1148 > spd:fl
1149 [e=-16.494 a=1]
1150```
1152---
1154### `++spn:fl`
1156Smallest normal
1158Produces the smallest representable normal float.
1160#### Source
1162```hoon
1163 ++ spn [e=emn a=(bex (dec prc))]
1164```
1166#### Examples
1168```
1169 > spn:fl
1170 [e=-16.494 a=5.192.296.858.534.827.628.530.496.329.220.096]
1171```
1173---
1175### `++lfn:fl`
1177Largest normal
1179Produces the largest representable normal float.
1181#### Source
1183```hoon
1184 ++ lfn [e=emx a=(fil 0 prc 1)]
1185```
1187#### Examples
1189```
1190 > lfn:fl
1191 [e=--16.271 a=10.384.593.717.069.655.257.060.992.658.440.191]
1192```
1194---
1196### `++lfe:fl`
1198Maximum
1200Produces the sum of `emx:fl` plus `prc:fl`.
1202#### Source
1204```hoon
1205 ++ lfe (sum:si emx (sun:si prc)) :: 2^lfe is > than all
1206```
1208#### Examples
1210```
1211 > lfe:fl
1212 --16.384
1213```
1215---
1217### `++zer:fl`
1219Zero
1221Produces zero represented as a float.
1223#### Source
1225```hoon
1226 ++ zer [e=--0 a=0]
1227 --
1228 |%
1229```
1231#### Examples
1233```
1234 > zer:fl
1235 [e=--0 a=0]
1236```
1238---
1240### `++rou:fl`
1242Round
1244Rounds `a`. The way in which `a` is rounded depends on the value of `r:fl`.
1246#### Accepts
1248`a` is an `fn`.
1250#### Produes
1252An `fn`.
1254#### Source
1256```hoon
1257 ++ rou
1258 |= [a=fn] ^- fn
1259 ?. ?=([$f *] a) a
1260 ?~ a.a [%f s.a zer]
1261 ?: s.a (^rou +>.a)
1262 =.(r swr (fli (^rou +>.a)))
1263```
1265#### Examples
1267```
1268 > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
1269 > (rou:fl [%f & --12 a])
1270 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1272 > (rou:fl [%f & --12 (add a 1)])
1273 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1275 > (rou:fl [%f & --12 (add a 300)])
1276 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1278 > (rou:fl [%f & --12 (add a 1.000)])
1279 [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
1280```
1282---
1284### `++syn:fl`
1286Get sign
1288Produces the sign of `a`.
1290#### Accepts
1292`a` is an `fn`.
1294#### Produes
1296An `fn`.
1298#### Source
1300```hoon
1301 ++ syn
1302 |= [a=fn] ^- ?
1303 ?-(-.a $f s.a, $i s.a, $n &)
1304```
1306#### Examples
1308```
1309 > (syn:fl (sun:fl 106))
1310 %.y
1312 > (syn:fl [%f | --0 106])
1313 %.n
1314```
1316---
1318### `++abs:fl`
1320Absolute value
1322Produces the absolute value of `a`.
1324#### Accepts
1326`a` is an `fn`.
1328#### Produes
1330An `fn`.
1332#### Sources
1334```hoon
1335 ++ abs
1336 |= [a=fn] ^- fn
1337 ?: ?=([$f *] a) [%f & e.a a.a]
1338 ?: ?=([$i *] a) [%i &] [%n ~]
1339```
1341#### Examples
1343```
1344 > (abs:fl [%f | --0 106])
1345 [%f s=%.y e=--0 a=106]
1347 > (abs:fl [%f & --0 106])
1348 [%f s=%.y e=--0 a=106]
1349```
1351---
1353### `++add:fl`
1355Add
1357Produces the sum of `a` plus `b`.
1359#### Accepts
1361`a` is an `fn`.
1363`b` is an `fn`.
1365#### Produces
1367An `fn`.
1369#### Source
1371```hoon
1372 ++ add
1373 |= [a=fn b=fn] ^- fn
1374 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1375 ?: |(?=([$i *] a) ?=([$i *] b))
1376 ?: &(?=([$i *] a) ?=([$i *] b))
1377 ?: =(a b) a [%n ~]
1378 ?: ?=([$i *] a) a b
1379 ?: |(=(a.a 0) =(a.b 0))
1380 ?. &(=(a.a 0) =(a.b 0)) %- rou ?~(a.a b a)
1381 [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer]
1382 %- |= [a=fn]
1383 ?. ?=([$f *] a) a
1384 ?. =(a.a 0) a
1385 [%f !=(r %d) zer]
1386 ?: =(s.a s.b)
1387 ?: s.a (^add +>.a +>.b |)
1388 =.(r swr (fli (^add +>.a +>.b |)))
1389 ?: s.a (^sub +>.a +>.b |)
1390 (^sub +>.b +>.a |)
1391```
1393#### Examples
1395```
1396 > (add:fl [%f & --0 106] [%f | --3 55])
1397 [%f s=%.n e=-104 a=6.774.324.807.619.657.921.598.381.929.529.344]
1398```
1400---
1402### `++ead:fl`
1404Exact add
1406Produces the exact sum of `a` plus `b`.
1408#### Accepts
1410`a` is an `fn`.
1412`b` is an `fn`.
1414#### Produces
1416An `fn`.
1418#### Source
1420```hoon
1421 ++ ead
1422 |= [a=fn b=fn] ^- fn
1423 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1424 ?: |(?=([$i *] a) ?=([$i *] b))
1425 ?: &(?=([$i *] a) ?=([$i *] b))
1426 ?: =(a b) a [%n ~]
1427 ?: ?=([$i *] a) a b
1428 ?: |(=(a.a 0) =(a.b 0))
1429 ?. &(=(a.a 0) =(a.b 0)) ?~(a.a b a)
1430 [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer]
1431 %- |= [a=fn]
1432 ?. ?=([$f *] a) a
1433 ?. =(a.a 0) a
1434 [%f !=(r %d) zer]
1435 ?: =(s.a s.b)
1436 ?: s.a (^add +>.a +>.b &)
1437 (fli (^add +>.a +>.b &))
1438 ?: s.a (^sub +>.a +>.b &)
1439 (^sub +>.b +>.a &)
1440 ::
1441```
1443#### Examples
1445```
1446 > (ead:fl [%f & --0 106] [%f | --3 55])
1447 [%f s=%.n e=--0 a=334]
1448```
1450---
1452### `++sub:fl`
1454Subtract
1456Produces the difference of `a` minus `b`.
1458#### Accepts
1460`a` is an `fn`.
1462`b` is an `fn`.
1464#### Produces
1466An `fn`.
1468#### Source
1470```hoon
1471 ++ sub
1472 |= [a=fn b=fn] ^- fn (add a (fli b))
1473```
1475#### Examples
1477```
1478 > (sub:fl [%f & --13 2.718] [%f & --23 11])
1479 [%f s=%.n e=-86 a=5.416.671.014.775.224.232.595.412.796.571.648]
1480```
1482---
1484### `++mul:fl`
1486Multiply
1488Produces the product of `a` multiplied by `b`.
1490#### Accepts
1492`a` is an `fn`.
1494`b` is an `fn`.
1496#### Produces
1498An `fn`.
1500#### Source
1502```hoon
1503 ++ mul
1504 |= [a=fn b=fn] ^- fn
1505 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1506 ?: ?=([$i *] a)
1507 ?: ?=([$i *] b)
1508 [%i =(s.a s.b)]
1509 ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1510 ?: ?=([$i *] b)
1511 ?: =(a.a 0) [%n ~] [%i =(s.a s.b)]
1512 ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer]
1513 ?: =(s.a s.b) (^mul +>.a +>.b)
1514 =.(r swr (fli (^mul +>.a +>.b)))
1515```
1517---
1519### `++emu:fl`
1521Exact multiply
1523Produces the exact product of `a` multiplied by `b`.
1525#### Accepts
1527`a` is an `fn`.
1529`b` is an `fn`.
1531#### Produces
1533An `fn`.
1535#### Examples
1537```
1538 ++ emu
1539 |= [a=fn b=fn] ^- fn
1540 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1541 ?: ?=([$i *] a)
1542 ?: ?=([$i *] b)
1543 [%i =(s.a s.b)]
1544 ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1545 ?: ?=([$i *] b)
1546 ?: =(a.a 0) [%n ~] [%i =(s.a s.b)]
1547 ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer]
1548 [%f =(s.a s.b) (sum:si e.a e.b) (^^mul a.a a.b)]
1549```
1551---
1553### `++div:fl`
1555Divide
1557Produces the quotient of `a` divided by `b`.
1559#### Accepts
1561`a` is an `fn`.
1563`b` is an `fn`.
1565#### Produces
1567An `fn`.
1569#### Divide
1571```hoon
1572 ++ div
1573 |= [a=fn b=fn] ^- fn
1574 ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1575 ?: ?=([$i *] a)
1576 ?: ?=([$i *] b) [%n ~] [%i =(s.a s.b)]
1577 ?: ?=([$i *] b) [%f =(s.a s.b) zer]
1578 ?: =(a.a 0) ?: =(a.b 0) [%n ~] [%f =(s.a s.b) zer]
1579 ?: =(a.b 0) [%i =(s.a s.b)]
1580 ?: =(s.a s.b) (^div +>.a +>.b)
1581 =.(r swr (fli (^div +>.a +>.b)))
1582```
1584---
1586### `++fma:fl`
1588Fused multiply-add
1590Produces the sum of `c` plus the product of `a` multiplied by `b`;
1591`(a * b) + c`.
1593#### Accepts
1595`a` is an `fn`.
1597`b` is an `fn`.
1599`c` is an `fn`.
1601#### Produces
1603An `fn`.
1605#### Source
1607```hoon
1608 ++ fma
1609 |= [a=fn b=fn c=fn] ^- fn
1610 (add (emu a b) c)
1611```
1613#### Examples
1615```
1616 > (fma:fl [%f & --13 2.718] [%f & --23 11] [%f & --13 2.718])
1617 [%f s=%.y e=-62 a=9.475.054.514.089.037.465.004.673.635.188.736]=
1618```
1620---
1622### `++sqt:fl`
1624Square root
1626Produces the square root of `a`.
1628#### Accepts
1630`a` is an `fn`.
1632#### Produces
1634An `fn`.
1636#### Source
1638```hoon
1639 ++ sqt
1640 |= [a=fn] ^- fn
1641 ?: ?=([$n *] a) [%n ~]
1642 ?: ?=([$i *] a) ?:(s.a a [%n ~])
1643 ?~ a.a [%f s.a zer]
1644 ?: s.a (^sqt +>.a) [%n ~]
1645```
1647#### Examples
1649```
1650 > (sqt:fl [%f s=%.y e=-18 a=342.602.577])
1651 [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
1652```
1654---
1656### `++inv:fl`
1658Inverse
1660Produces the inverse of `a` by dividing `1` by `a`.
1662#### Accepts
1664`a` is an `fn`.
1666#### Produces
1668An `fn`.
1670#### Source
1672```hoon
1673 ++ inv
1674 |= [a=fn] ^- fn
1675 (div [%f & --0 1] a)
1676```
1678#### Examples
1680```
1681 > (inv:fl [%f s=%.y e=--0 a=10])
1682 [%f s=%.y e=-116 a=8.307.674.973.655.724.205.648.794.126.752.154]
1683 > (drg:fl [%f s=%.y e=-116 a=8.307.674.973.655.724.205.648.794.126.752.154])
1684 [%d s=%.y e=-1 a=1]
1686 > (inv:fl [%f s=%.y e=--1 a=10])
1687 [%f s=%.y e=-117 a=8.307.674.973.655.724.205.648.794.126.752.154]
1688 > (drg:fl [%f s=%.y e=-117 a=8.307.674.973.655.724.205.648.794.126.752.154])
1689 [%d s=%.y e=-2 a=5]
1691 > (inv:fl [%f s=%.y e=--2 a=10])
1692 [%f s=%.y e=-118 a=8.307.674.973.655.724.205.648.794.126.752.154]
1693 > (drg:fl [%f s=%.y e=-118 a=8.307.674.973.655.724.205.648.794.126.752.154])
1694 [%d s=%.y e=-3 a=25]
1695```
1697---
1699### `++sun:fl`
1701Signed integer to float
1703Produces `a` in floating-point representation.
1705#### Accepts
1707`a` is an unsigned integer.
1709#### Produces
1711An `fn`.
1713#### Source
1715```hoon
1716 ++ sun
1717 |= [a=@u] ^- fn
1718 (rou [%f & --0 a])
1719```
1721#### Examples
1723```
1724 > (sun:fl 0)
1725 [%f s=%.y e=--0 a=0]
1727 > (sun:fl 5.048.729)
1728 [%f s=%.y e=-90 a=6.250.023.776.601.238.669.911.180.544.311.296]
1730 > (sun:fl -100)
1731 ! exit
1732```
1734---
1736### `++san:fl`
1738Signed integer to float
1740Produces the floating-point representation of `a`, an unsigned integer.
1742#### Accepts
1744`a` is an unsigned integer.
1746#### Produces
1748An `fn`.
1750#### Source
1752```hoon
1753 ++ san
1754 |= [a=@s] ^- fn
1755 =+ b=(old:si a)
1756 (rou [%f -.b --0 +.b])
1757```
1759#### Examples
1761```
1762 > (san:fl --100)
1763 [%f s=%.y e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1765 > (san:fl -100)
1766 [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1767```
1769---
1771### `++lth:fl`
1773Less than
1775Tests if `a` is less than `b`. Returns `~` in the event of `a` or `b` being a
1776NaN (`[%n ~]`).
1778#### Accepts
1780`a` is an `fn`.
1782`b` is an `fn`.
1784#### Produces
1786A `unit` of `flag`.
1788#### Source
1790```hoon
1791 ++ lth
1792 |= [a=fn b=fn] ^- (unit ?)
1793 ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1794 ?: =(a b) |
1795 ?: ?=([$i *] a) !s.a ?: ?=([$i *] b) s.b
1796 ?: |(=(a.a 0) =(a.b 0))
1797 ?: &(=(a.a 0) =(a.b 0)) |
1798 ?: =(a.a 0) s.b !s.a
1799 ?: !=(s.a s.b) s.b
1800 ?: s.a (^lth +>.a +>.b) (^lth +>.b +>.a)
1801```
1803#### Examples
1805```
1806 > (lth:fl (sun:fl 116) (sun:fl 4.820))
1807 [~ u=%.y]
1809 > (lth:fl (sun:fl 218.116) (sun:fl 4.820))
1810 [~ u=%.n]
1812 > (lth:fl (sun:fl 218.116) [%n ~])
1814```
1816---
1818### `++lte:fl`
1820Less than or equal
1822Tests whether `a` is less than or equal to `b`. Returns `~` in the event of `a`
1823or `b` being a NaN (`[%n ~]`).
1825#### Accepts
1827`a` is an `fn`.
1829`b` is an `fn`.
1831#### Produces
1833A `unit` of `flag`.
1835#### Source
1837```hoon
1838 ++ lte
1839 |= [a=fn b=fn] ^- (unit ?)
1840 %+ bind (lth b a) |= a=? !a
1841```
1843#### Examples
1845```
1846 > (lte:fl (sun:fl 102) [%f %.y -5 973.655.724])
1847 [~ u=%.y]
1849 > (lte:fl (sun:fl 102) [%f %.y -24 973.655.724])
1850 [~ u=%.n]
1852 > (lte:fl [%f %.y --2 25] (sun:fl 100))
1853 [~ u=%.y]
1855 > (lte:fl [%f %.y --2 25] [%f %.y --3 2])
1856 [~ u=%.n]
1858 > (lte:fl [%f %.y --2 25] [%n ~])
1860```
1862---
1864### `++equ:fl`
1866Equals
1868Tests if `a` is equal to `b`. Returns `~` in the event of `a` or `b` being a NaN
1869(`[%n ~]`).
1871#### Accepts
1873`a` is an `fn`.
1875`b` is an `fn`.
1877#### Produces
1879An `unit` of `flag`.
1881#### Source
1883```hoon
1884 ++ equ
1885 |= [a=fn b=fn] ^- (unit ?)
1886 ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1887 ?: =(a b) &
1888 ?: |(?=([$i *] a) ?=([$i *] b)) |
1889 ?: |(=(a.a 0) =(a.b 0))
1890 ?: &(=(a.a 0) =(a.b 0)) & |
1891 ?: |(=(e.a e.b) !=(s.a s.b)) |
1892 (^equ +>.a +>.b)
1893```
1895#### Examples
1897```
1898 > (equ:fl [%f %.y --2 25] (sun:fl 100))
1899 [~ u=%.y]
1901 > (equ:fl [%f %.y --2 25] (sun:fl 101))
1902 [~ u=%.n]
1903```
1905---
1907### `++gte:fl`
1909Greater or equal than
1911Tests whether `a` is greater than or equal to `b`. Returns `~` in the event of
1912`a` or `b` being a NaN (`[%n ~]`).
1914#### Accepts
1916`a` is an `fn`.
1918`b` is an `fn`.
1920#### Produces
1922An `unit` of `flag`.
1924#### Source
1926```hoon
1927 ++ gte
1928 |= [a=fn b=fn] ^- (unit ?) (lte b a)
1929```
1931#### Examples
1933```
1934 > (gte:fl [%f %.y --2 25] (sun:fl 100))
1935 [~ u=%.y]
1937 > (gth:fl [%f %.y --6 73.989] [%f %.y --5 919.599])
1938 [~ u=%.n]
1940 > (gth:fl [%f %.y --6 73.989] [%n ~])
1942```
1944---
1946### `++gth:fl`
1948Greater than
1950Tests whether `a` is greater than `b`. Returns `~` in the event of `a` or `b`
1951being a NaN (`[%n ~]`).
1953#### Accepts
1955`a` is an `fn`.
1957`b` is an `fn`.
1959#### Produces
1961An `unit` of `flag`.
1963#### Source
1965```hoon
1966 ++ gth
1967 |= [a=fn b=fn] ^- (unit ?) (lth b a)
1968```
1970#### Examples
1972```
1973 > (gth:fl [%f %.y --2 25] (sun:fl 100))
1974 [~ u=%.n]
1976 > (gth:fl [%f %.y --6 73.989] [%f %.y --5 119.599])
1977 [~ u=%.y]
1978```
1980---
1982### `++drg:fl`
1984Float to decimal
1986Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
1987accurate results for rounded floats.
1989#### Accepts
1991`a` is an `fn`.
1993#### Produces
1995A `dn`.
1997#### Source
1999```hoon
2000 ++ drg
2001 |= [a=fn] ^- dn
2002 ?: ?=([$n *] a) [%n ~]
2003 ?: ?=([$i *] a) [%i s.a]
2004 ?~ a.a [%d s.a --0 0]
2005 [%d s.a (^drg +>.a)]
2006```
2008#### Examples
2010```
2011 > (drg:fl [%f | --6 73.989])
2012 [%d s=%.n e=--0 a=4.735.296]
2013```
2015---
2017### `++grd:fl`
2019Decimal to float
2021Converts decimal `a` to `fn`.
2023#### Accepts
2025`a` is a `dn`.
2027#### Produces
2029An `fn`.
2031#### Source
2033```hoon
2034 ++ grd
2035 |= [a=dn] ^- fn
2036 ?: ?=([$n *] a) [%n ~]
2037 ?: ?=([$i *] a) [%i s.a]
2038 => .(r %n)
2039 =+ q=(abs:si e.a)
2040 ?: (syn:si e.a)
2041 (mul [%f s.a --0 a.a] [%f & e.a (pow 5 q)])
2042 (div [%f s.a --0 a.a] [%f & (sun:si q) (pow 5 q)])
2043```
2045#### Examples
2047```
2048 > (grd:fl [%d s=%.n e=--0 a=73.989])
2049 [%f s=%.n e=-96 a=5.862.012.516.267.904.074.208.723.341.410.304]
2051 > (grd:fl [%d s=%.n e=--0 a=100])
2052 [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
2053```
2055---
2057### `++toi:fl`
2059Round to signed integer
2061Rounds `a` to the nearest signed integer.
2063#### Accepts
2065`a` is an `fn`.
2067#### Produces
2069A `unit` of @s.
2071#### Source
2073```hoon
2074 ++ toi
2075 |= [a=fn] ^- (unit @s)
2076 =+ b=(toj a)
2077 ?. ?=([$f *] b) ~ :- ~
2078 =+ c=(^^mul (bex (abs:si e.b)) a.b)
2079 (new:si s.b c)
2080```
2082#### Examples
2084```
2085 > (toi:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514.406.400])
2086 [~ u=--26.843.545.600]
2087```
2089---
2091### `++toj:fl`
2093Round to integer fn
2095Rounds `a` to the nearest decimal integer.
2097#### Accepts
2099`a` is an `fn`.
2101#### Produces
2103A `unit` of @s.
2105#### Source
2107```hoon
2108 ++ toj
2109 |= [a=fn] ^- fn
2110 ?. ?=([$f *] a) a
2111 ?~ a.a [%f s.a zer]
2112 ?: s.a (^toj +>.a)
2113 =.(r swr (fli (^toj +>.a)))
2114 --
2115```
2117#### Examples
2119```
2120 > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514.406.400])
2121 [%f s=%.y e=--0 a=26.843.545.600]
2123 > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514])
2124 [%f s=%.y e=--0 a=26.844]
2126 > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460])
2127 [%f s=%.y e=--0 a=0]
2129 > (toj:fl [%f s=%.y e=-9 a=9.002])
2130 [%f s=%.y e=--0 a=16]
2131```
2133---
2135## `++ff`
2137IEEE-754 Formatting
2139Container core for IEEE-754 formatting operations.
2141- `w` is width: The number of bits in the exponent field.
2142- `p` is precision: The number of bits in the significand field.
2143- `w` is bias: Added to exponent when storing.
2144- `r` is rounding mode: Possible modes are nearest (`$n`), up (`$u`),
2145 down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%a`.
2147#### Source
2149```hoon
2150 ++ ff
2151 |_ [[w=@u p=@u b=@s] r=$?($n $u $d $z $a)]
2152```
2154#### Examples
2156```
2157 > =ffcore ~(. ff [8 8 0] %n)
2158 > ffcore
2159 <24.ltg {{{@ud @ud @ud} r/$n} <54.tyv 119.wim 31.ohr 1.jmk $143>}>
2161```
2163---
2165#### Discussion
2167`++ff` has no use outside of the functionality provided to other cores: `++rd`,
2168`++rs`, `++rq`, and `++rh`. It's not intended to be used directly; it's just
2169meant to power those cores.
2171---
2173### `++sb:ff`
2175Sign bit
2177Produces the sign bit of `++ff`.
2179#### Source
2181```hoon
2182 ++ sb (bex (^add w p))
2183```
2185#### Examples
2187```
2188 > sb:ff
2190```
2192---
2194### `++me:ff`
2196Minimum exponent
2198Produces the minimum possible exponent of `ff`.
2200#### Source
2202```hoon
2203 ++ me (dif:si (dif:si --1 b) (sun:si p))
2204```
2206#### Examples
2208```
2209 > me:ff
2210 --1
2211```
2213---
2215### `++pa:ff`
2217Initialize `fl`
2219Instantiates the core `fl`, giving values to its samples based on the
2220configuration of the `ff` core.
2222#### Source
2224```hoon
2225 ++ pa
2226 %*(. fl p +(p), v me, w (^sub (bex w) 3), d %d, r r)
2227```
2229#### Examples
2231```
2232 > ~(pa ff [11 52 --1.023] %n)
2233 < 23.qzd
2234 28.btz
2235 { {{p/@ v/@s w/@} r/?($n $u $a $d $z) d/$d}
2236 <54.tyv 119.wim 31.ohr 1.jmk $143>
2239```
2241#### Discussion
2243`++pa` exists exclusively for internal use of `++ff`, and `++ff` exists for
2244internal use in other cores.
2246---
2248### `++sea:ff`
2250`@r` to `fn`
2252Converts `a` from `@r` to `fn`.
2254#### Accepts
2256`a` is a `@r`, an IEEE float.
2258#### Produces
2260A `unit` of @s.
2262#### Source
2264```hoon
2265 ++ sea
2266 |= [a=@r] ^- fn
2267 =+ [f=(cut 0 [0 p] a) e=(cut 0 [p w] a)]
2268 =+ s=(sig a)
2269 ?: =(e 0)
2270 ?: =(f 0) [%f s --0 0] [%f s me f]
2271 ?: =(e (fil 0 w 1))
2272 ?: =(f 0) [%i s] [%n ~]
2273 =+ q=:(sum:si (sun:si e) me -1)
2274 =+ r=(^add f (bex p))
2275 [%f s q r]
2276```
2278#### Examples
2280```
2281 > (sea:ff `@r`0x8)
2282 [%f s=%.y e=--0 a=0]
2283```
2285---
2287### `++bit:ff`
2289`fn` to `@r`, rounding
2291Converts `a` from `fn` to `@r` and applies rounding.
2293#### Accepts
2295`a` is an `fn`.
2297#### Produces
2299A `@r`.
2301#### Source
2303```hoon
2304 ++ bit |= [a=fn] (bif (rou:pa a))
2305```
2307#### Examples
2309```
2310 > (bit:ma:rd [%f | -6 202])
2311 0xc009400000000000
2312```
2314---
2316### `++bif:ff`
2318`fn` to `@r`, no rounding
2320Converts `a` from `fn` to `@r`. No rounding is applied.
2322#### Accepts
2324`a` is a `@r`, an IEEE float.
2326#### Produces
2328A `flag`.
2330#### Source
2332```hoon
2333 ++ bif
2334 |= [a=fn] ^- @r
2335 ?: ?=([$i *] a)
2336 =+ q=(lsh 0 p (fil 0 w 1))
2337 ?: s.a q (^add q sb)
2338 ?: ?=([$n *] a) (lsh 0 (dec p) (fil 0 +(w) 1))
2339 ?~ a.a ?: s.a `@r`0 sb
2340 =+ ma=(met 0 a.a)
2341 ?. =(ma +(p))
2342 ?> =(e.a me)
2343 ?> (^lth ma +(p))
2344 ?: s.a `@r`a.a (^add a.a sb)
2345 =+ q=(sum:si (dif:si e.a me) --1)
2346 =+ r=(^add (lsh 0 p (abs:si q)) (end 0 p a.a))
2347 ?: s.a r (^add r sb)
2348```
2350#### Examples
2352```
2353 > (bif:ma:rd *fn)
2354 0x7ff8000000000000
2355```
2357---
2359### `++sig:ff`
2361Get sign
2363Produces the sign of `a`.
2365#### Accepts
2367`a` is a `@r`, an IEEE float.
2369#### Produces
2371A `flag`.
2373#### Source
2375```hoon
2376 ++ sig
2377 |= [a=@r] ^- ?
2378 =(0 (cut 0 [(^add p w) 1] a))
2379```
2381#### Examples
2383```
2384 > (sig:ff `@r`5)
2385 %.n
2386```
2388---
2390### `++exp:ff`
2392Get exponent
2394Produces the exponent of `a`.
2396#### Accepts
2398`a` is a `@r`, an IEEE float.
2400#### Produces
2402A signed integer.
2404#### Source
2406```hoon
2407 ++ exp
2408 |= [a=@r] ^- @s
2409 (dif:si (sun:si (cut 0 [p w] a)) b)
2410```
2412#### Examples
2414```
2415 > (exp:ff `@r`5)
2416 --0
2417```
2419---
2421### `++add:ff`
2423Add
2425Produces the sum of `a` plus `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#### Source
2439```hoon
2440 ++ add
2441 |= [a=@r b=@r]
2442 (bif (add:pa (sea a) (sea b)))
2443```
2445#### Examples
2447```
2448 > (add:ma:rd `@r`5 `@r`11)
2449 0x10
2450```
2452---
2454### `++sub:ff`
2456Sub
2458Produces the sum of `a` plus `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 ++ sub
2474 |= [a=@r b=@r]
2475 (bif (sub:pa (sea a) (sea b)))
2476```
2478#### Examples
2480```
2481 > (sub:ma:rd `@r`5 `@r`11)
2482 0x8000000000000006
2483```
2485---
2487### `++mul:ff`
2489Multiply
2491Produces the product of `a` multiplied by `b`.
2493#### Accepts
2495`a` is a `@r`, an IEEE float.
2497`b` is a `@r`, an IEEE float.
2499#### Produces
2501A `@r`, an IEEE float.
2503#### Multiply
2505```hoon
2506 ++ mul
2507 |= [a=@r b=@r]
2508 (bif (mul:pa (sea a) (sea b)))
2509```
2511#### Examples
2513```
2514 > (mul:ma:rd `@r`11 `@r`2)
2515 0x0
2516```
2518---
2520### `++div:ff`
2522Divide
2524Produces the quotient of `a` divided by `b`.
2526#### Accepts
2528`a` is a `@r`, an IEEE float.
2530`b` is a `@r`, an IEEE float.
2532#### Produces
2534A `@r`, an IEEE float.
2536#### Source
2538```hoon
2539 ++ div
2540 |= [a=@r b=@r]
2541 (bif (div:pa (sea a) (sea b)))
2542```
2544#### Examples
2546```
2547 > (div:ma:rd `@r`175 `@r`26)
2548 0x401aec4ec4ec4ec4
2549```
2551---
2553### `++fma:ff`
2555Fused multiply-add
2557Produces the sum of `c` plus the product of `a` multiplied by `b`;
2558`(a * b) + c`.
2560#### Accepts
2562`a` is a `@r`, an IEEE float.
2564`b` is a `@r`, an IEEE float.
2566`c` is a `@r`, an IEEE float.
2568#### Produces
2570A `@r`, an IEEE float.
2572#### Source
2574```hoon
2575 ++ fma
2576 |= [a=@r b=@r c=@r]
2577 (bif (fma:pa (sea a) (sea b) (sea c)))
2578```
2580#### Examples
2582```
2583 > (fma:ma:rd `@r`175 `@r`26 `@r`100)
2584 0x64
2585```
2587---
2589### `++sqt:ff`
2591Square root
2593Produces the square root of `a`.
2595#### Accepts
2597`a` is a `@r`, an IEEE float.
2599#### Produces
2601A `@r`, an IEEE float.
2603#### Source
2605```hoon
2606 ++ sqt
2607 |= [a=@r]
2608 (bif (sqt:pa (sea a)))
2609```
2611#### Examples
2613```
2614 > (sqt:ma:rd `@r`175)
2615 0x1e9a751f9447b724
2616```
2618---
2620### `++lth:ff`
2622Less than
2624Tests whether `a` is less than `b`.
2626#### Accepts
2628`a` is a `@r`, an IEEE float.
2630`b` is a `@r`, an IEEE float.
2632#### Produces
2634A `flag`.
2636#### Source
2638```hoon
2639 ++ lth
2640 |= [a=@r b=@r] (fall (lth:pa (sea a) (sea b)) |)
2641```
2643#### Examples
2645```
2646 > (lth:ma:rd `@rd`1 `@rd`2)
2647 %.y
2649 > (lth:ma:rd `@rd`10 `@rd`2)
2650 %.n
2651```
2653---
2655### `++lte:ff`
2657Less than or equal to
2659Tests whether `a` is less than or equal to `b`.
2661#### Accepts
2663`a` is a `@r`, an IEEE float.
2665`b` is a `@r`, an IEEE float.
2667#### Produces
2669A `flag`.
2671#### Source
2673```hoon
2674 ++ lte
2675 |= [a=@r b=@r] (fall (lte:pa (sea a) (sea b)) |)
2676```
2678#### Examples
2680```
2681 > (lte:ma:rd `@rd`10 `@rd`2)
2682 %.n
2684 > (lte:ma:rd `@rd`10 `@rd`10)
2685 %.y
2686```
2688---
2690### `++equ:ff`
2692Equals
2694Tests whether `a` is equal to `b`.
2696#### Accepts
2698`a` is a `@r`, an IEEE float.
2700`b` is a `@r`, an IEEE float.
2702#### Produces
2704A `flag`.
2706#### Source
2708```hoon
2709 ++ equ
2710 |= [a=@r b=@r] (fall (equ:pa (sea a) (sea b)) |)
2711```
2713#### Examples
2715```
2716 > (equ:ma:rd `@rd`10 `@rd`2)
2717 %.n
2719 > (equ:ma:rd `@rd`10 `@rd`10)
2720 %.y
2721```
2723---
2725### `++gte:ff`
2727Greater or equal than
2729Tests whether `a` is greater than or equal to `b`.
2731#### Accepts
2733`a` is a `@r`, an IEEE float.
2735`b` is a `@r`, an IEEE float.
2737#### Produces
2739A `flag`.
2741#### Source
2743```hoon
2744 ++ gte
2745 |= [a=@r b=@r] (fall (gte:pa (sea a) (sea b)) |)
2746```
2748#### Examples
2750```
2751 > (gte:ma:rd `@rd`10 `@rd`10)
2752 %.y
2754 > (gte:ma:rd `@rd`10 `@rd`11)
2755 %.n
2756```
2758---
2760### `++gth:ff`
2762Greater than
2764Tests whether `a` is greater than or equal to `b`.
2766#### Accepts
2768`a` is a `@r`, an IEEE float.
2770`b` is a `@r`, an IEEE float.
2772#### Produces
2774A `flag`.
2776#### Source
2778```hoon
2779 ++ gth
2780 |= [a=@r b=@r] (fall (gth:pa (sea a) (sea b)) |)
2781```
2783#### Examples
2785```
2786 > (gth:ma:rd `@rd`10 `@rd`10)
2787 %.n
2789 > (gth:ma:rd `@rd`10 `@rd`9)
2790 %.y
2791```
2793---
2795### `++sun:ff`
2797Unsigned integer to `@r`
2799Converts `a` from an unsigned integer (`@u`) to `@r`.
2801#### Accepts
2803`a` is `@u`, unsigned integer.
2805#### Produces
2807A `@r`, an IEEE float.
2809#### Source
2811```hoon
2812 ++ sun
2813 |= [a=@u] (bit [%f & --0 a])
2814```
2816#### Examples
2818```
2819 > (sun:ma:rd 658.149.282)
2820 0x41c39d47d1000000
2821```
2823---
2825### `++san:ff`
2827Signed integer to `@r`
2829Converts `a` from a signed integer to `@r`.
2831#### Accepts
2833`a` is `@s`, an unsigned integer
2835#### Produces
2837A `@r`, an IEEE float.
2839#### Source
2841```hoon
2842 ++ san
2843 |= [a=@s] (bit [%f (syn:si a) --0 (abs:si a)])
2844```
2846#### Examples
2848```
2849 > (san:ma:rd --10)
2850 0x4024000000000000
2851```
2853---
2855### `++toi:ff`
2857Round to integer
2859Rounds `a` to the nearest signed integer.
2861#### Accepts
2863`a` is a `@r`, an IEEE float.
2865#### Produces
2867A `flag` of `@s`.
2869#### Source
2871```hoon
2872 ++ toi
2873 |= [a=@r] (toi:pa (sea a))
2874```
2876#### Examples
2878```
2879 > (toi:ma:rd `@r`0x4af)
2880 [~ u=--0]
2881```
2883---
2885### `++drg:ff`
2887`@r` to decimal float
2889Converts `a` from `@r` to `dn` using the Dragon4 algorithm.
2891#### Accepts
2893`a` is a `@r`, an IEEE float.
2895#### Produces
2897A `dn`.
2899#### Source
2901```hoon
2902 ++ drg
2903 |= [a=@r] (drg:pa (sea a))
2904```
2906#### Examples
2908```
2909 > (drg:ma:rd `@r`0x41c0)
2910 [%d s=%.y e=-323 a=8.316]
2912 > (drg:ma:rd (sun:ma:rd 658.149.282))
2913 [%d s=%.y e=--0 a=658.149.282]
2914```
2916---
2918### `++grd:ff`
2920Decimal float to `@r`
2922Converts `a` from `dn` to `@r`.
2924#### Accepts
2926`a` is a `dn`.
2928#### Produces
2930A `@r`, an IEEE float.
2932#### Source
2934```hoon
2935 ++ grd
2936 |= [a=dn] (bif (grd:pa a))
2937 --
2938```
2940#### Examples
2942```
2943 > (grd:ma:rd [%d s=%.y e=--0 a=658.149.282])
2944 0x41c39d47d1000000
2945```
2947---
2949## `++rlyd`
2951Prep `@rd` for print
2953Converts `a` from a double-precision binary float to decimal64.
2955#### Accepts
2957`a` is a `@rd`, a double-precision float.
2959#### Produces
2961A `dn`.
2963#### Source
2965```hoon
2966 ++ rlyd |= a=@rd ^- dn (drg:rd a)
2967```
2969#### Examples
2971```
2972 > (rlyd .~2.4703e-320)
2973 [%d s=%.y e=-324 a=24.703]
2974```
2976---
2978## `++rlys`
2980Prep @rs for print
2982Converts `a` from a single-precision binary float to decimal32.
2984#### Accepts
2986`a` is a `@rs`, a single-precision float.
2988#### Produces
2990A `dn`.
2992#### Source
2994```hoon
2995 ++ rlys |= a=@rs ^- dn (drg:rs a)
2996```
2998#### Examples
3000```
3001 > (rlys .1.681557e-39)
3002 [%d s=%.y e=-45 a=1.681.557]
3003```
3005---
3007## `++rlyh`
3009Prep `@rh` for print
3011Converts `a` from a half-precision binary float to decimal16.
3013#### Accepts
3015`a` is a `@rh`, a half-precision float.
3017#### Produces
3019A `dn`.
3021#### Source
3023```hoon
3024 ++ rlyh |= a=@rh ^- dn (drg:rh a)
3025```
3027#### Examples
3029```
3030 > (rlyh .~~3e1)
3031 [%d s=%.y e=--1 a=3]
3032```
3034---
3036## `++rlyq`
3038Prep `@rq` for print
3040Converts `a` from a quad-precision binary float to decimal128.
3042#### Accepts
3044`a` is a `@rq`, a quad-precision float.
3046#### Produces
3048A `dn`.
3050#### Source
3052```hoon
3053 ++ rlyq |= a=@rq ^- dn (drg:rq a)
3054```
3056#### Examples
3058```
3059 > (rlyq .~~~2.2628017865927756787440310766086816e-4343)
3060 [%d s=%.y e=-4.377 a=22.628.017.865.927.756.787.440.310.766.086.816]
3061```
3063---
3065## `++ryld`
3067Finish parsing `@rd`
3069Converts `a` from a decimal float to a double-precision binary float.
3071#### Accepts
3073`a` is a `dn`.
3075#### Produces
3077A a `@rd`, a double-precision float.
3079#### Source
3081```hoon
3082 ++ ryld |= a=dn ^- @rd (grd:rd a)
3083```
3085#### Examples
3087```
3088 > (ryld [%d s=%.y e=-324 a=24.703])
3089 .~2.4703e-320
3090```
3092---
3094## `++ryls`
3096Finish parsing `@rs`
3098Converts `a` from a decimal float to a single-precision binary float.
3100#### Accepts
3102`a` is a `dn`.
3104#### Produces
3106A a `@rs`, a single-precision float.
3108#### Source
3110```hoon
3111 ++ ryls |= a=dn ^- @rs (grd:rs a)
3112```
3114#### Examples
3116```
3117 > (ryls [%d s=%.y e=-324 a=24.703])
3118 .0
3120 > (ryls [%d s=%.y e=-32 a=24.703])
3121 .2.4703e-28
3122```
3124---
3126## `++rylh`
3128Finish parsing `@rh`
3130Converts `a` from a decimal float to a half-precision binary float.
3132#### Accepts
3134`a` is a `dn`.
3136#### Produces
3138A a `@rh`, a half-precision float.
3140#### Source
3142```hoon
3143 ++ rylh |= a=dn ^- @rh (grd:rh a)
3144```
3146#### Examples
3148```
3149 > (rylh [%d s=%.y e=--1 a=703])
3150 .~~7.032e3
3152 > (rylh [%d s=%.y e=--3 a=56])
3153 .~~5.6e4
3155 > (rylh [%d s=%.y e=--4 a=56])
3156 .~~inf
3157```
3159---
3161## `++rylq`
3163Finish parsing `@rq`
3165Converts `a` from a decimal float to a quad-precision binary float.
3167#### Accepts
3169`a` is a `dn`.
3171#### Produces
3173A a `@rq`, a quad-precision float.
3175#### Source
3177```hoon
3178 ++ rylq |= a=dn ^- @rq (grd:rq a)
3179```
3181#### Examples
3183```
3184 > (rylq [%d s=%.y e=-324 a=24.703])
3185 .~~~2.4703e-320
3186```
3188---
3190## `++rd`
3192Double-precision fp
3194A container core for operations related to double-precision binary floats.
3196`++rd` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3197down (`$d`), and round to zero (`$z`).
3199#### Source
3201```hoon
3202 ++ rd
3203 ^?
3204 ~% %rd +> ~
3205 |_ r=$?($n $u $d $z)
3206```
3208---
3210### `++ma:rd`
3212Initialize `ff`
3214Instantiates the core `ff`, giving values to its samples based on the
3215configuration of the `rd` core.
3217#### Source
3219```hoon
3220 ++ ma
3221 %*(. ff w 11, p 52, b --1.023, r r)
3222```
3224#### Examples
3226```
3227 > ~(ma rd %n)
3228 < 24.ltg
3229 {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3231```
3233---
3235### `++sea:rd`
3237`@rd` to `fn`
3239Converts `a` from a double-precision binary float to `fn`.
3241```hoon
3242 ++ sea :: @rd to fn
3243 |= [a=@rd] (sea:ma a)
3244```
3246#### Examples
3248```
3249 > (sea:rd .~4.94066e-319)
3250 [%f s=%.y e=-1.074 a=100.000]
3251```
3253---
3255### `++bit:rd`
3257`fn` to `@rd`
3259Converts `a` from `fn` to a double-precision binary float.
3261#### Accepts
3263`a` is an `fn`.
3265#### Produces
3267A `@rd`, a double-precision float.
3269#### Source
3271```hoon
3272 ++ bit
3273 |= [a=fn] ^- @rd (bit:ma a)
3274```
3276#### Examples
3278```
3279 > (bit:rd [%f s=%.y e=-1.074 a=100.000])
3280 .~4.94066e-319
3281```
3283---
3285### `++add:rd`
3287Add
3289Produces the sum of `a` plus `b`.
3291#### Accepts
3293`a` is a `@rd`, a double-precision float.
3295`b` is a `@rd`, a double-precision float.
3297#### Produces
3299A `@rd`.
3301#### Source
3303```hoon
3304 ++ add ~/ %add
3305 |= [a=@rd b=@rd] ^- @rd
3306 ~_ leaf+"rd-fail"
3307 (add:ma a b)
3308```
3310#### Examples
3312```
3313 > (add:rd .~3.94066e12 .~9.2846e11)
3314 .~4.86912e12
3315```
3317---
3319### `++sub:rd`
3321Subtract
3323Produces the difference of `a` minus `b`.
3325#### Accepts
3327`a` is a `@rd`, a double-precision float.
3329`b` is a `@rd`, a double-precision float.
3331#### Produces
3333A `@rd`.
3335#### Source
3337```hoon
3338 ++ sub ~/ %sub
3339 |= [a=@rd b=@rd] ^- @rd
3340 ~_ leaf+"rd-fail"
3341 (sub:ma a b)
3342```
3344#### Examples
3346```
3347 > (sub:rd .~7.94069e2 .~1.2846e3)
3348 .~-4.9053099999999995e2
3349```
3351---
3353### `++mul:rd`
3355Multiply
3357Produces the product of `a` times `b`.
3359#### Accepts
3361`a` is a `@rd`, a double-precision float.
3363`b` is a `@rd`, a double-precision float.
3365#### Produces
3367A `@rd`.
3369#### Source
3371```hoon
3372 ++ mul ~/ %mul
3373 |= [a=@rd b=@rd] ^- @rd
3374 ~_ leaf+"rd-fail"
3375 (mul:ma a b)
3376```
3378#### Examples
3380```
3381 > (mul:rd .~7.94069e2 .~1.2246e3)
3382 .~9.724168973999998e5
3383```
3385---
3387### `++div:rd`
3389Divide
3391Produces the quotient of `a` divided by `b`.
3393#### Accepts
3395`a` is a `@rd`, a double-precision float.
3397`b` is a `@rd`.
3399#### Produces
3401A `@rd`.
3403#### Source
3405```hoon
3406 ++ div ~/ %div
3407 |= [a=@rd b=@rd] ^- @rd
3408 ~_ leaf+"rd-fail"
3409 (div:ma a b)
3410```
3412#### Examples
3414```
3415 > (div:rd .~7.94099e2 .~1.2246e3)
3416 .~6.484558223093255e-1
3417```
3419---
3421### `++fma:rd`
3423Fused multiply-add
3425Produces the sum of `c` plus the product of `a` multiplied by `b`;
3426`(a * b) + c`.
3428#### Accepts
3430`a` is a `@rd`, an IEEE float.
3432`b` is a `@rd`.
3434`c` is a `@rd`.
3436#### Produces
3438A `@rd`.
3440#### Source
3442#### Source
3444```hoon
3445 ++ fma ~/ %fma
3446 |= [a=@rd b=@rd c=@rd] ^- @rd
3447 ~_ leaf+"rd-fail"
3448 (fma:ma a b c)
3449```
3451#### Examples
3453```
3454 > (fma:rd .~7.94099e2 .~1.2246e3 .~3.94066e3)
3455 .~9.763942954e5
3456```
3458---
3460### `++sqt:rd`
3462Square root
3464Produces the square root of `a`.
3466#### Accepts
3468`a` is a `@rd`, a double-precision float.
3470#### Produces
3472A `@rd`.
3474#### Source
3476```hoon
3477 ++ sqt ~/ %sqt
3478 |= [a=@rd] ^- @rd ~_ leaf+"rd-fail"
3479 (sqt:ma a)
3480```
3482#### Examples
3484```
3485 > (sqt:rd .~3.94066e3)
3486 .~6.2774676422901614e1
3487```
3489---
3491### `++lth:rd`
3493Less than
3495Test whether `a` is less than `b`.
3497#### Accepts
3499`a` is a `@rd`, a double-precision float.
3501`b` is a `@rd`, a double-precision float.
3503#### Produces
3505A `@rd`.
3507#### Source
3509```hoon
3510 ++ lth ~/ %lth
3511 |= [a=@rd b=@rd]
3512 ~_ leaf+"rd-fail"
3513 (lth:ma a b)
3514```
3516#### Examples
3518```
3519 > (lth:rd .~7.94099e2 .~1.2246e3)
3520 %.y
3522 > (lth:rd .~7.94099e2 .~1.2246e2)
3523 %.n
3525 > (lth:rd .~1.2246e2 .~1.2246e2)
3526 %.n
3527```
3529---
3531### `++lte:rd`
3533Less than or equal
3535Test whether `a` is less than or equal to `b`.
3537#### Accepts
3539`a` is a `@rd`, a double-precision float.
3541`b` is a `@rd`, a double-precision float.
3543#### Produces
3545A `@rd`.
3547#### Source
3549```hoon
3550 ++ lte ~/ %lte :: less-equals
3551 |= [a=@rd b=@rd]
3552 ~_ leaf+"rd-fail"
3553 (lte:ma a b)
3554```
3556#### Examples
3558```
3559 > (lte:rd .~7.94099e2 .~1.2246e3)
3560 %.y
3562 > (lte:rd .~7.94099e2 .~1.2246e2)
3563 %.n
3565 > (lte:rd .~1.2246e2 .~1.2246e2)
3566 %.y
3567```
3569---
3571### `++equ:rd`
3573Equals
3575Test whether `a` is equal to `b`.
3577#### Accepts
3579`a` is a `@rd`, a double-precision float.
3581`b` is a `@rd`, a double-precision float.
3583#### Produces
3585A `@rd`.
3587#### Source
3589```hoon
3590 ++ equ ~/ %equ
3591 |= [a=@rd b=@rd]
3592 ~_ leaf+"rd-fail"
3593 (equ:ma a b)
3594```
3596#### Examples
3598```
3599 > (equ:rd .~7.94099e2 .~1.2246e3)
3600 %.n
3602 > (equ:rd .~7.94099e2 .~1.2246e2)
3603 %.n
3605 > (equ:rd .~1.2246e2 .~1.2246e2)
3606 %.y
3607```
3609---
3611### `++gte:rd`
3613Greater than or equal
3615Test whether `a` is greater than or equal to `b`.
3617#### Accepts
3619`a` is a `@rd`, a double-precision float.
3621`b` is a `@rd`, a double-precision float.
3623#### Produces
3625A `@rd`.
3627#### Source
3629```hoon
3630 ++ gte ~/ %gte
3631 |= [a=@rd b=@rd]
3632 ~_ leaf+"rd-fail"
3633 (gte:ma a b)
3634```
3636#### Examples
3638```
3639 > (gte:rd .~7.94099e2 .~1.2246e3)
3640 %.n
3642 > (gte:rd .~7.94099e2 .~1.2246e2)
3643 %.y
3645 > (gte:rd .~1.2246e2 .~1.2246e2)
3646 %.y
3647```
3649---
3651### `++gth:rd`
3653Greater than
3655Test whether `a` is greater `b`.
3657#### Accepts
3659`a` is a `@rd`, a double-precision float.
3661`b` is a `@rd`, a double-precision float.
3663#### Produces
3665A `@rd`.
3667#### Source
3669```hoon
3670 ++ gth ~/ %gth
3671 |= [a=@rd b=@rd]
3672 ~_ leaf+"rd-fail"
3673 (gth:ma a b)
3674```
3676#### Examples
3678```
3679 > (gth:rd .~7.94099e2 .~1.2246e3)
3680 %.n
3682 > (gth:rd .~7.94099e2 .~1.2246e2)
3683 %.y
3685 > (gth:rd .~1.2246e2 .~1.2246e2)
3686 %.n
3687```
3689---
3691### `++sun:rd`
3693Unsigned integer to `@rd`
3695Converts an unsigned integer `a` to `@rd`.
3697#### Accepts
3699`a` is a `@u`, an unsigned integer.
3701#### Produces
3703A `@rd`.
3705#### Source
3707```hoon
3708 ++ sun |= [a=@u] ^- @rd (sun:ma a)
3709```
3711#### Examples
3713```
3714 > (sun:rd 511)
3715 .~5.11e2
3716```
3718---
3720### `++san:rd`
3722Unsigned integer to `@rd`
3724Converts a signed integer `a` to `@rd`.
3726#### Accepts
3728`a` is a `@s`, a signed integer.
3730#### Produces
3732A `@rd`.
3734#### Source
3736```hoon
3737 ++ san |= [a=@s] ^- @rd (san:ma a)
3738```
3740#### Examples
3742```
3743 > (san:rd -511)
3744 .~-5.11e2
3745```
3747---
3749### `++sig:rd`
3751Get sign
3753Produces the sign of `a`.
3755#### Accepts
3757`a` is a `@rd`
3759#### Produces
3761A `flag`.
3763#### Source
3765```hoon
3766 ++ sig |= [a=@rd] ^- ? (sig:ma a)
3767```
3769#### Examples
3771```
3772 > (sig:rd .~1.2246e3)
3773 %.y
3774```
3776---
3778### `++exp:rd`
3780Get exponent
3782Produces the exponent of `a`.
3784#### Accepts
3786`a` is a `@rd`
3788#### Produces
3790A `@s`.
3792#### Source
3794```hoon
3795 ++ exp |= [a=@rd] ^- @s (exp:ma a) :: get exponent
3796```
3798#### Examples
3800```
3801 > (exp:rd .~1.2246e3)
3802 --10
3803```
3805---
3807### `++toi:rd`
3809Round to integer
3811Rounds `a` to the nearest integer.
3813#### Accepts
3815`a` is a `@rd`
3817#### Produces
3819A `unit` of `@s`.
3821#### Source
3823```hoon
3824 ++ toi |= [a=@rd] ^- (unit @s) (toi:ma a)
3825```
3827#### Examples
3829```
3830 > (toi:rd .~1.2246e3)
3831 [~ u=--1.224]
3832```
3834---
3836### `++drg:rd`
3838`@rd` to decimal float
3840Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
3841accurate results for rounded floats.
3843#### Accepts
3845`a` is a `@rd`
3847#### Produces
3849A `dn`.
3851#### Source
3853```hoon
3854 ++ drg |= [a=@rd] ^- dn (drg:ma a)
3855```
3857#### Examples
3859```
3860 > (drg:rd .~1.2246e3)
3861 [%d s=%.y e=-1 a=12.246]
3862```
3864---
3866### `++grd:rd`
3868Decimal float to `@rd`
3870Converts `a` from decimal float to `@rd`.
3872#### Accepts
3874`a` is a `@dn`
3876#### Produces
3878A `@rd`.
3880#### Source
3882```hoon
3883 ++ grd |= [a=dn] ^- @rd (grd:ma a) :: decimal float to @rd
3884 --
3885```
3887#### Examples
3889```
3890 > (grd:rd [%d s=%.y e=-1 a=12.246])
3891 .~1.2246e3
3892```
3894---
3896## `++rs`
3898Single-precision fp
3900A container core for operations related to single-precision binary floats.
3902`++rs` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3903down (`$d`), and round to zero (`$z`).
3905#### Source
3907```hoon
3908 ++ rs
3909 ~% %rs +> ~
3910 ^?
3911 |_ r=$?($n $u $d $z)
3912```
3914---
3916### `++ma:rs`
3918Initialize `ff`
3920Instantiates the core `ff`, giving values to its samples based on the
3921configuration of the `rs` core.
3923#### Source
3925```hoon
3926 ++ ma
3927 %*(. ff w 8, p 23, b --127, r r)
3928```
3930#### Examples
3932```
3933 > ~(ma rs %n)
3934 < 24.ltg
3935 {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3937```
3939---
3941### `++sea:rs`
3943`@rs` to `fn`
3945Converts `a` from `@rs` to `fn`.
3947#### Accepts
3949`a` is a `@rs`, an single-precision float.
3951#### Produces
3953An `fn`.
3955#### Source
3957```hoon
3958 ++ sea
3959 |= [a=@rs] (sea:ma a)
3960```
3962#### Examples
3964```
3965 > (sea:rs .1.4e-43)
3966 [%f s=%.y e=-149 a=100]
3967```
3969---
3971### `++bit:rs`
3973`fn` to `@rs`
3975Converts `a` from `fn` to `@rs`.
3977#### Accepts
3979`a` is an `fn`.
3981#### Produces
3983A `@rs`, a single-precision float.
3985#### Source
3987```hoon
3988 ++ bit
3989 |= [a=fn] ^- @rs (bit:ma a)
3990```
3992#### Examples
3994```
3995 > (bit:rs [%f & -2 1.000])
3996 .2.5e2
3997```
3999---
4001### `++add:rs`
4003Add
4005Produces the sum of `a` plus `b`.
4007#### Accepts
4009`a` is a `@rs`, a single-precision float.
4011`b` is a `@rs`.
4013#### Produces
4015A `@rs`.
4017#### Source
4019```hoon
4020 ++ add ~/ %add
4021 |= [a=@rs b=@rs] ^- @rs
4022 ~_ leaf+"rs-fail"
4023 (add:ma a b)
4024```
4026#### Examples
4028```
4029 > (add:rs .2.5e1 .2.5e2)
4030 .2.75e2
4031```
4033---
4035### `++sub:rs`
4037Subtract
4039Subtracts `a` from `b`.
4041#### Source
4043```hoon
4044 ++ sub ~/ %sub
4045 |= [a=@rs b=@rs] ^- @rs
4046 ~_ leaf+"rs-fail"
4047 (sub:ma a b)
4048```
4050#### Examples
4052```
4053 > (sub:rs .2.5e1 .2.5e2)
4054 .-2.25e2
4055```
4057---
4059### `++mul:rs`
4061Multiply
4063Produces the product of `a` multiplied by `b`.
4065#### Accepts
4067`a` is a `@rs`, a single-precision float.
4069`b` is a `@rs`.
4071#### Produces
4073A `@rs`.
4075#### Source
4077```hoon
4078 ++ mul ~/ %mul
4079 |= [a=@rs b=@rs] ^- @rs
4080 ~_ leaf+"rs-fail"
4081 (mul:ma a b)
4082```
4084#### Examples
4086```
4087 > (mul:rs .2.5e1 .2.5e2)
4088 .6.25e3
4089```
4091---
4093### `++div:rs`
4095Divide
4097Produces the quotient of `a` divided by `b`.
4099#### Accepts
4101`a` is a `@rs`, a single-precision float.
4103`b` is a `@rs`.
4105#### Produces
4107A `@rs`.
4109#### Source
4111```hoon
4112 ++ div ~/ %div
4113 |= [a=@rs b=@rs] ^- @rs
4114 ~_ leaf+"rs-fail"
4115 (div:ma a b)
4116```
4118#### Examples
4120```
4121 > (div:rs .4.5e1 .2.2e2)
4122 .2.0454545e-1
4123```
4125---
4127### `++fma:rs`
4129Fused multiply-add
4131Produces the sum of `c` plus the product of `a` multiplied by `b`;
4132`(a * b) + c`.
4134#### Accepts
4136`a` is a `@rs`, a single-precision float.
4138`b` is a `@rs`.
4140`c` is a `@rs`.
4142#### Produces
4144A `@rs`.
4146#### Source
4148```hoon
4149 ++ fma ~/ %fma
4150 |= [a=@rs b=@rs c=@rs] ^- @rs
4151 ~_ leaf+"rs-fail"
4152 (fma:ma a b c)
4153```
4155#### Examples
4157```
4158 > (fma:rs .2.5e1 .2.5e2 .8.2e1)
4159 .6.332e3
4160```
4162---
4164### `++sqt:rs`
4166Square root
4168Produces the square root of `a`.
4170#### Accepts
4172`a` is a `@rs`, a single-precision float.
4174#### Produces
4176A `@rs`.
4178#### Source
4180```hoon
4181 ++ sqt ~/ %sqt
4182 |= [a=@rs] ^- @rs
4183 ~_ leaf+"rs-fail"
4184 (sqt:ma a)
4185```
4187#### Examples
4189```
4190 > (sqt:rs .2.5e2)
4191 .1.5811388e1
4192```
4194---
4196### `++lth:rs`
4198Less than
4200Test whether `a` is less than `b`.
4202#### Accepts
4204`a` is a `@rs`, a single-precision float.
4206`b` is a `@rs`.
4208#### Produces
4210A `@rs`.
4212#### Source
4214```hoon
4215 ++ lth ~/ %lth
4216 |= [a=@rs b=@rs]
4217 ~_ leaf+"rs-fail"
4218 (lth:ma a b)
4219```
4221#### Examples
4223```
4224 > (lth:rs .9.9e1 .1.1e2)
4225 %.y
4227 > (lth:rs .9.9e1 .9.9e1)
4228 %.n
4229```
4231---
4233### `++lte:rs`
4235Less than or equal
4237Test whether `a` is less than or equal to `b`.
4239#### Accepts
4241`a` is a `@rs`, a single-precision float.
4243`b` is a `@rs`.
4245#### Produces
4247A `@rs`.
4249#### Source
4251```hoon
4252 ++ lte ~/ %lte
4253 |= [a=@rs b=@rs]
4254 ~_ leaf+"rs-fail"
4255 (lte:ma a b)
4256```
4258#### Examples
4260```
4261 > (lte:rs .9.9e1 .1.1e2)
4262 %.y
4264 > (lte:rs .9.9e1 .9.9e1)
4265 %.y
4266```
4268---
4270### `++equ:rs`
4272Equals
4274Test whether `a` is equal to `b`.
4276#### Accepts
4278`a` is a `@rs`, a single-precision float.
4280`b` is a `@rs`.
4282#### Produces
4284A `@rs`.
4286#### Source
4288```hoon
4289 ++ equ ~/ %equ
4290 |= [a=@rs b=@rs]
4291 ~_ leaf+"rs-fail"
4292 (equ:ma a b)
4293```
4295#### Examples
4297```
4298 > (equ:rs .9.9e1 .1.1e2)
4299 %.n
4301 > (equ:rs .9.9e1 .9.9e1)
4302 %.y
4303```
4305---
4307### `++gte:rs`
4309Greater than or equal
4311Test whether `a` is greater than or equal to `b`.
4313#### Accepts
4315`a` is a `@rs`, a single-precision float.
4317`b` is a `@rs`.
4319#### Produces
4321A `@rs`.
4323#### Source
4325```hoon
4326 ++ gte ~/ %gte
4327 |= [a=@rs b=@rs]
4328 ~_ leaf+"rs-fail"
4329 (gte:ma a b)
4330```
4332#### Examples
4334```
4335 > (gte:rs .9.9e1 .9.9e1)
4336 %.y
4338 > (gte:rs .9.9e1 .9.2e2)
4339 %.n
4340```
4342---
4344### `++gth:rs`
4346Greater than
4348Test whether `a` is greater than `b`.
4350#### Accepts
4352`a` is a `@rs`, a single-precision float.
4354`b` is a `@rs`.
4356#### Produces
4358A `@rs`.
4360#### Source
4362```hoon
4363 ++ gth ~/ %gth
4364 |= [a=@rs b=@rs]
4365 ~_ leaf+"rs-fail"
4366 (gth:ma a b)
4367```
4369#### Examples
4371```
4372 > (gth:rs .9.9e1 .9.2e2)
4373 %.n
4375 > (gth:rs .9.9e1 .9.9e1)
4376 %.n
4378 > (gth:rs .9.9e1 .1.9e1)
4379 %.y
4380```
4382---
4384### `++sun:rs`
4386Unsigned integer to `@rs`
4388Converts `a` from an unsigned integer to `@rs`.
4390#### Accepts
4392`a` is an unsigned integer.
4394#### Produces
4396A `@rs`.
4398#### Source
4400```hoon
4401 ++ sun |= [a=@u] ^- @rs (sun:ma a)
4402```
4404#### Examples
4406```
4407 > (sun:rs 343)
4408 .3.43e2
4409```
4411---
4413### `++san:rs`
4415Signed integer to `@rs`'
4417Converts `a` from an unsigned integer to `@rs`.
4419#### Accepts
4421`a` is a signed integer.
4423#### Produces
4425A `@rs`.
4427#### Source
4429```hoon
4430 ++ san |= [a=@s] ^- @rs (san:ma a)
4431```
4433#### Examples
4435```
4436 > (san:rs -343)
4437 .-3.43e2'
4438```
4440### `++sig:rs`
4442Get sign
4444Produces the sign of `a`.
4446#### Accepts
4448`a` is a `@rs`.
4450#### Produces
4452A `flag`.
4454#### Source
4456```hoon
4457 ++ sig |= [a=@rs] ^- ? (sig:ma a)
4458```
4460#### Examples
4462```
4463 > (sig:rs .3.43e2)
4464 %.y
4466 > (sig:rs .-3.43e2)
4467 %.n
4468```
4470---
4472### `++exp:rs`
4474Get exponent
4476Produces the exponent of `a`.
4478#### Accepts
4480`a` is a `@rs`.
4482#### Produces
4484A signed integer.
4486#### Source
4488```hoon
4489 ++ exp |= [a=@rs] ^- @s (exp:ma a)
4490```
4492#### Examples
4494```
4495 > (exp:rs .-3.43e2)
4496 --8
4497```
4499---
4501### `++toi:rs`
4503Round to integer
4505Rounds `a` to the nearest integer.
4507#### Accepts
4509`a` is a `@rs`.
4511#### Produces
4513A `unit` of `@s`.
4515#### Source
4517```hoon
4518 ++ toi |= [a=@rs] ^- (unit @s) (toi:ma a)
4519```
4521#### Examples
4523```
4524 > (toi:rs .-3.43e2)
4525 [~ u=-343]
4526```
4528---
4530### `++drg:rs`
4532`@rs` to decimal float
4534Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
4535accurate results for rounded floats.
4537#### Accepts
4539`a` is a `@rs`
4541#### Produces
4543A `dn`.
4545#### Source
4547```hoon
4548 ++ drg |= [a=@rs] ^- dn (drg:ma a)
4549```
4551#### Examples
4553```
4554 > (drg:rs .-3.43e2)
4555 [%d s=%.n e=--0 a=343]
4556```
4558---
4560### `++grd:rs`
4562Decimal float to `@rs`
4564Converts `a` from `dn` to `@rs`.
4566#### Accepts
4568`a` is a `dn`.
4570#### Produces
4572A `@rs`.
4574#### Source
4576```hoon
4577 ++ grd |= [a=dn] ^- @rs (grd:ma a)
4578 --
4579```
4581#### Examples
4583```
4584 > (grd:rs [%d s=%.n e=--0 a=343])
4585 .-3.43e2
4586```
4588---
4590## `++rq`
4592Quadruple-precision fp
4594A container core for operations related to quadruple-precision binary floats.
4596`++rq` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
4597down (`$d`), and round to zero (`$z`).
4599#### Source
4601```hoon
4602 ++ rq
4603 ~% %rq +> ~
4604 ^?
4605 |_ r=$?($n $u $d $z)
4606```
4608### `++ma:rq`
4610Initialize `ff`
4612Instantiates the core `ff`, giving values to its samples based on the
4613configuration of the `rq` core.
4615#### Source
4617```hoon
4618 ++ ma
4619 %*(. ff w 15, p 112, b --16.383, r r)
4620```
4622---
4624### `++sea:rq`
4626`@rq` to `fn`
4628Converts `a` from `@rq` to `fn`.
4630#### Accepts
4632`a` is a `@rq`, a quad-precision float.
4634#### Produces
4636An `fn`.
4638#### Source
4640```hoon
4641 ++ sea
4642 |= [a=@rq] (sea:ma a)
4643```
4645#### Examples
4647```
4648 > (sea:rq .~~~1.05102e5)
4649 [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272]
4650```
4652---
4654### `++bit:rq`
4656`fn` to `@rq`
4658Converts `a` from `fn` to `@rq`.
4660#### Accepts
4662`a` is an `fn`.
4664#### Produces
4666A `@rq`, a quad-precision float.
4668#### Source
4670```hoon
4671 ++ bit
4672 |= [a=n] ^- @rq (bit:ma a)
4673```
4675#### Examples
4677```
4678 > (bit:rq [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272])
4679 .~~~1.05102e5
4680```
4682---
4684### `++add:rq`
4686Add
4688Produces the sum of `a` plus `b`.
4690#### Accepts
4692`a` is a `@rq`, a quad-precision float.
4694`b` is a `@rq`.
4696#### Produces
4698A `@rq`.
4700#### Source
4702```hoon
4703 ++ add ~/ %add
4704 |= [a=@rq b=@rq] ^- @rq
4705 ~_ leaf+"rq-fail"
4706 (add:ma a b)
4707```
4709#### Examples
4711```
4712 > (add:rq .~~~-1.821e5 .~~~1.05102e5)
4713 .~~~-7.6998e4
4714```
4716---
4718### `++sub:rq`
4720Subtract
4722Produces the difference of `a` minus `b`.
4724#### Accepts
4726`a` is a `@rq`, a quad-precision float.
4728`b` is a `@rq`.
4730#### Produces
4732A `@rq`.
4734#### Source
4736```hoon
4737 ++ sub ~/ %sub
4738 |= [a=@rq b=@rq] ^- @rq
4739 ~_ leaf+"rq-fail"
4740 (sub:ma a b)
4741```
4743#### Examples
4745```
4746 > (sub:rq .~~~1.821e5 .~~~1.05102e5)
4747 .~~~7.6998e4
4749 > (sub:rq .~~~1.821e5 .~~~-1.05102e5)
4750 .~~~2.87202e5
4751```
4753---
4755### `++mul:rq`
4757Multiply
4759Produces the product of `a` times `b`.
4761#### Accepts
4763`a` is a `@rq`, a quad-precision float.
4765`b` is a `@rq`.
4767#### Produces
4769A `@rq`.
4771#### Source
4773```hoon
4774 ++ mul ~/ %mul
4775 |= [a=@rq b=@rq] ^- @rq
4776 ~_ leaf+"rq-fail"
4777 (mul:ma a b)
4778```
4780#### Examples
4782```
4783 > (mul:rq .~~~1.821e5 .~~~-1.05102e5)
4784 .~~~-1.91390742e10
4785```
4787---
4789### `++div:rq`
4791Divide
4793Produces the product of `a` divided by `b`.
4795#### Accepts
4797`a` is a `@rq`, a quad-precision float.
4799`b` is a `@rq`.
4801#### Produces
4803A `@rq`.
4805#### Source
4807```hoon
4808 ++ div ~/ %div
4809 |= [a=@rq b=@rq] ^- @rq
4810 ~_ leaf+"rq-fail"
4811 (div:ma a b)
4812```
4814#### Examples
4816```
4817 > (div:rq .~~~1.821e5 .~~~1.05102e3)
4818 .~~~1.732602614602957127361991208540275e2
4819```
4821---
4823### `++fma:rq`
4825Fused multiply-add
4827Produces the sum of `c` plus the product of `a` multiplied by `b`;
4828`(a * b) + c`.
4830#### Accepts
4832`a` is a `@rq`, a quad-precision float.
4834`b` is a `@rq`.
4836`c` is a `@rq`.
4838#### Produces
4840A `@rq`.
4842#### Source
4844```hoon
4845 ++ fma ~/ %fma
4846 |= [a=@rq b=@rq c=@rq] ^- @rq
4847 ~_ leaf+"rq-fail"
4848 (fma:ma a b c)
4849```
4851#### Examples
4853```
4854 > (fma:rq .~~~1.821e5 .~~~-1.05102e2 .~~~6.2044e7)
4855 .~~~4.29049258e7
4856```
4858---
4860### `++sqt:rq`
4862Square root
4864Produces the square root of `a`.
4866#### Accepts
4868`a` is a `@rq`, a quad-precision float.
4870#### Produces
4872A `@rq`.
4874#### Source
4876```hoon
4877 ++ sqt ~/ %sqt
4878 |= [a=@rq] ^- @rq
4879 ~_ leaf+"rq-fail"
4880 (sqt:ma a)
4881```
4883#### Examples
4885```
4886 > (sqt:rq .~~~6.2044e7)
4887 .~~~7.876801381271461258959876570289002e3
4888```
4890---
4892### `++lth:rq`
4894Less than
4896Tests whether `a` is less than `b`.
4898#### Accepts
4900`a` is a `@rq`, a quad-precision float.
4902`b` is a `@rq`.
4904#### Produces
4906A `@rq`.
4908#### Source
4910```hoon
4911 ++ lth ~/ %lth
4912 |= [a=@rq b=@rq]
4913 ~_ leaf+"rq-fail"
4914 (lth:ma a b)
4915```
4917#### Examples
4919```
4920 > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4921 %.n
4923 > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4924 %.y
4925```
4927---
4929### `++lte:rq`
4931Less than or equal
4933Tests whether `a` is less than or equal to `b`.
4935#### Accepts
4937`a` is a `@rq`, a quad-precision float.
4939`b` is a `@rq`.
4941#### Produces
4943A `@rq`.
4945#### Source
4947```hoon
4948 ++ lte ~/ %lte
4949 |= [a=@rq b=@rq]
4950 ~_ leaf+"rq-fail"
4951 (lte:ma a b)
4952```
4954#### Examples
4956```
4957 > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4958 %.n
4960 > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4961 %.y
4963 > (lte:rq .~~~1.2044e7 .~~~1.2044e7)
4964 %.y
4965```
4967---
4969### `++equ:rq`
4971Equals
4973Tests whether `a` is equal to `b`.
4975#### Accepts
4977`a` is a `@rq`, a quad-precision float.
4979`b` is a `@rq`.
4981#### Produces
4983A `@rq`.
4985#### Source
4987```hoon
4988 ++ equ ~/ %equ
4989 |= [a=@rq b=@rq]
4990 ~_ leaf+"rq-fail"
4991 (equ:ma a b)
4992```
4994#### Examples
4996```
4997 > (equ:rq .~~~1.2044e7 .~~~1.2044e7)
4998 %.y
5000 > (equ:rq .~~~2.2044e7 .~~~1.2044e7)
5001 %.n
5002```
5004---
5006### `++gte:rq`
5008Greater than or equal
5010Tests whether `a` is greater than or equal to `b`.
5012#### Accepts
5014`a` is a `@rq`, a quad-precision float.
5016`b` is a `@rq`.
5018#### Produces
5020A `@rq`.
5022#### Source
5024```hoon
5025 ++ gte ~/ %gte
5026 |= [a=@rq b=@rq]
5027 ~_ leaf+"rq-fail"
5028 (gte:ma a b)
5029```
5031#### Examples
5033```
5034 > (gte:rq .~~~1.2044e7 .~~~1.2044e7)
5035 %.y
5037 > (gte:rq .~~~2.2044e7 .~~~1.2044e7)
5038 %.y
5040 > (gte:rq .~~~1.2044e7 .~~~2.2044e7)
5041 %.n
5042```
5044---
5046### `++gth:rq`
5048Tests whether `a` is greater than `b`.
5050#### Accepts
5052`a` is a `@rq`, a quad-precision float.
5054`b` is a `@rq`.
5056#### Produces
5058A `@rq`.
5060#### Source
5062```hoon
5063 ++ gth ~/ %gth
5064 |= [a=@rq b=@rq]
5065 ~_ leaf+"rq-fail"
5066 (gth:ma a b)
5067```
5069#### Examples
5071```
5072 > (gth:rq .~~~1.2044e7 .~~~1.2044e7)
5073 %.n
5075 > (gth:rq .~~~2.2044e7 .~~~1.2044e7)
5076 %.y
5078 > (gth:rq .~~~1.2044e7 .~~~2.2044e7)
5079 %.n
5080```
5082---
5084### `++sun:rq`
5086Unsigned integer to `@rq`
5088Converts `@` from an unsigned integer to `@rq`.
5090#### Accepts
5092`a` is a `@u`, an unsigned integer.
5094#### Produces
5096A `@rq`, a quad-precision float.
5098#### Source
5100```hoon
5101 ++ sun |= [a=@u] ^- @rq (sun:ma a)
5102```
5104#### Examples
5106```
5107 > (sun:rq 205)
5108 .~~~2.05e2
5109```
5111---
5113### `++san:rq`
5115Signed integer to `rq`
5117Converts `@` from a signed integer to `@rq`.
5119#### Accepts
5121`a` is a `@s`, a signed integer.
5123#### Produces
5125A `@rq`, a quad-precision float.
5127#### Source
5129```hoon
5130 ++ san |= [a=@s] ^- @rq (san:ma a)
5131```
5133#### Examples
5135```
5136 > (san:rq -205)
5137 .~~~-2.05e2
5138```
5140---
5142### `++sig:rq`
5144Get sign
5146Produces the sign of `a`.
5148#### Accepts
5150`a` is a `@rq`, a quad-precision float.
5152#### Produces
5154A `flag`.
5156#### Source
5158```hoon
5159 ++ sig |= [a=@rq] ^- ? (sig:ma a)
5160```
5162#### Examples
5164```
5165 > (sig:rq .~~~-2.05e2)
5166 %.n
5167```
5169---
5171### `++exp:rq`
5173Get exponent
5175Gets the exponent of `a`.
5177#### Accepts
5179`a` is a `@rq`, a quad-precision float.
5181#### Produces
5183A `@s`, a signed integer.
5185#### Source
5187```hoon
5188 ++ exp |= [a=@rq] ^- @s (exp:ma a)
5189```
5191#### Examples
5193```
5194 > (exp:rq .~~~-2.05e2)
5195 --7
5196```
5198---
5200### `++toi:rq`
5202Round to integer
5204Rounds `a` to the nearest integer.
5206#### Accepts
5208`a` is a `@rq`, a quad-precision float.
5210#### Produces
5212A `unit` of `@s`.
5214#### Source
5216```hoon
5217 ++ toi |= [a=@rq] ^- (unit @s) (toi:ma a)
5218```
5220#### Examples
5222```
5223 > (toi:rq .~~~-2.085e2)
5224 [~ u=-208]
5226 > (toi:rq .~~~-2.08e2)
5227 [~ u=-208]
5228```
5230---
5232### `++drg:rq`
5234`@rq` to decimal float
5236Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5237accurate results for rounded floats.
5239#### Accepts
5241`a` is a `@rq`, a quad-precision float.
5243#### Produces
5245A `dn`.
5247#### Source
5249```hoon
5250 ++ drg |= [a=@rq] ^- dn (drg:ma a) :: @rq to decimal float
5251```
5253#### Examples
5255```
5256 > (drg:rq .~~~-2.085e2)
5257 [%d s=%.n e=-1 a=2.085]
5259 > (drg:rq .~~~-2.08e2)
5260 [%d s=%.n e=--0 a=208]
5261```
5263---
5265### `++grd:rq`
5267Decimal float to `@rq`
5269Converts `a` from `dn` to `@rq`.
5271#### Accepts
5273`a` is `dn`.
5275`a` is a `@rq`.
5277#### Produces
5279A `@rq`, a quad-precision float.
5281#### Source
5283```hoon
5284 ++ grd |= [a=dn] ^- @rq (grd:ma a)
5285 --
5286```
5288#### Examples
5290```
5291 > (grd:rq [%d s=%.n e=--0 a=343])
5292 .~~~-3.43e2
5293```
5295---
5297## `++rh`
5299Half-precision fp
5301A container core for operations related to half-precision binary floats.
5303`++rh` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
5304down (`$d`), and round to zero (`$z`).
5306#### Source
5308```hoon
5309 ++ rh
5310 ~% %rh +> ~
5311 ^?
5312 |_ r=$?($n $u $d $z)
5313```
5315---
5317### `++ma:rh`
5319Initialize `ff`
5321Instantiates the core `ff`, giving values to its samples based on the
5322configuration of the `rh` core.
5324#### Source
5326```hoon
5327 ++ ma
5328 %*(. ff w 5, p 10, b --15, r r)
5329```
5331---
5333### `++sea:rh`
5335`@rh` to `fn`
5337Converts `a` from `@rh` to `fn`.
5339#### Accepts
5341`a` is a `@rh`, a half-precision float.
5343#### Produces
5345An `fn`.
5347#### Source
5349```hoon
5350 ++ sea
5351 |= [a=@rh] (sea:ma a)
5352```
5354#### Examples
5356```
5357 > (sea:rh .~~1.22e-5)
5358 [%f s=%.y e=-24 a=205]
5359```
5361---
5363### `++bit:rh`
5365`fn` to `@rh`
5367Converts `a` from `fn` to `@rh`.
5369#### Accepts
5371`a` is an `fn`.
5373#### Produces
5375A `@rh`, a half-precision float.
5377#### Source
5379```hoon
5380 ++ bit
5381 |= [a=fn] ^- @rh (bit:ma a)
5382```
5384#### Examples
5386```
5387 > (bit:rh [%f s=%.y e=-24 a=205])
5388 .~~1.22e-5
5389```
5391---
5393### `++add:rh`
5395Produces the sum of `a` plus `b`.
5397#### Accepts
5399`a` is a `@rh`, a half-precision float.
5401`b` is a `@rh`.
5403#### Produces
5405A `@rh`.
5407#### Source
5409```hoon
5410 ++ add ~/ %add
5411 |= [a=@rh b=@rh] ^- @rh
5412 ~_ leaf+"rh-fail"
5413 (add:ma a b)
5414```
5416#### Examples
5418```
5419 > (add:rh .~~1.82e2 .~~1.02e2)
5420 .~~2.84e2
5421```
5423---
5425### `++sub:rh`
5427Subtract
5429Produces the difference of `a` minus `b`.
5431#### Accepts
5433`a` is a `@rh`, a half-precision float.
5435`b` is a `@rh`.
5437#### Produces
5439A `@rh`.
5441#### Source
5443```hoon
5444 ++ sub ~/ %sub
5445 |= [a=@rh b=@rh] ^- @rh
5446 ~_ leaf+"rh-fail"
5447 (sub:ma a b)
5448```
5450#### Examples
5452```
5453 > (sub:rh .~~1.821e2 .~~1.051e2)
5454 .~~7.7e1
5456 > (sub:rh .~~1.821e2 .~~6.051e2)
5457 .~~-4.228e2
5458```
5460---
5462### `++mul:rh`
5464Multiply
5466Produces the product of `a` times `b`.
5468#### Accepts
5470`a` is a `@rh`, a quad-precision float.
5472`b` is a `@rh`.
5474#### Produces
5476A `@rh`.
5478#### Source
5480```hoon
5481 ++ mul ~/ %mul
5482 |= [a=@rh b=@rh] ^- @rh
5483 ~_ leaf+"rh-fail"
5484 (mul:ma a b)
5485```
5487#### Examples
5489```
5490 > (mul:rh .~~1.821e1 .~~-1.05102e2)
5491 .~~-1.913e3
5492```
5494---
5496### `++div:rh`
5498Divide
5500Produces the product of `a` divided by `b`.
5502#### Accepts
5504`a` is a `@rh`, a half-precision float.
5506`b` is a `@rh`.
5508#### Produces
5510A `@rh`.
5512#### Source
5514```hoon
5515 ++ div ~/ %div
5516 |= [a=@rh b=@rh] ^- @rh
5517 ~_ leaf+"rh-fail"
5518 (div:ma a b)
5519```
5521#### examples
5523```
5524 > (div:rh .~~1.821e3 .~~1.05102e2)
5525 .~~1.731e1
5526```
5528---
5530### `++fma:rh`
5532Fused multiply-add
5534Produces the sum of `c` plus the product of `a` multiplied by `b`;
5535`(a * b) + c`.
5537#### Accepts
5539`a` is a `@rh`, a half-precision float.
5541`b` is a `@rh`.
5543`c` is a `@rh`.
5545#### Produces
5547A `@rh`.
5549#### Source
5551```hoon
5552 ++ fma ~/ %fma
5553 |= [a=@rh b=@rh c=@rh] ^- @rh
5554 ~_ leaf+"rh-fail"
5555 (fma:ma a b c)
5556```
5558#### Examples
5560```
5561 > (fma:rh .~~1.821e4 .~~-1.05102e2 .~~6.2044e3)
5562 .~~-6.55e4
5563```
5565---
5567### `++sqt:rh`
5569Square root
5571Produces the square root of `a`.
5573#### Accepts
5575`a` is a `@rh`, a half-precision float.
5577#### Produces
5579A `@rh`.
5581#### Source
5583```hoon
5584 ++ sqt ~/ %sqt
5585 |= [a=@rh] ^- @rh
5586 ~_ leaf+"rh-fail"
5587 (sqt:ma a)
5588```
5590#### Source
5592```hoon
5593 > (sqt:rh .~~6.24e4)
5594 .~~2.498e2
5595```
5597---
5599### `++lth:rh`
5601Less than
5603Tests whether `a` is less than `b`.
5605#### Accepts
5607`a` is a `@rh`, a half-precision float.
5609`b` is a `@rh`.
5611#### Produces
5613A `@rh`.
5615#### Source
5617```hoon
5618 ++ lth ~/ %lth
5619 |= [a=@rh b=@rh]
5620 ~_ leaf+"rh-fail"
5621 (lth:ma a b)
5622```
5624#### Examples
5626```
5627 > (lth:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5628 %.n
5630 > (lth:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5631 %.y
5632```
5634---
5636### `++lte:rh`
5638Less than or equal
5640Tests whether `a` is less than or equal to `b`.
5642#### Accepts
5644`a` is a `@rh`, a half-precision float.
5646`b` is a `@rh`.
5648#### Produces
5650A `@rh`.
5652#### Source
5654```hoon
5655 ++ lte ~/ %lte
5656 |= [a=@rh b=@rh]
5657 ~_ leaf+"rh-fail"
5658 (lte:ma a b)
5659```
5661#### Examples
5663```
5664 > (lte:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5665 %.n
5667 > (lte:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5668 %.y
5670 > (lte:rh .~~1.2e3 .~~1.2e3)
5671 %.y
5672```
5674---
5676### `++equ:rh`
5678Equals
5680Tests whether `a` is equal to `b`.
5682#### Accepts
5684`a` is a `@rh`, a half-precision float.
5686`b` is a `@rh`.
5688#### Produces
5690A `@rh`.
5692#### Source
5694```hoon
5695 ++ equ ~/ %equ
5696 |= [a=@rh b=@rh]
5697 ~_ leaf+"rh-fail"
5698 (equ:ma a b)
5699```
5701#### Examples
5703```
5704 > (equ:rh .~~1.24e4 .~~1.24e4)
5705 %.y
5707 > (equ:rh .~~2.24e4 .~~1.24e4)
5708 %.n
5709```
5711---
5713### `++gte:rh`
5715Greater than or equal
5717Tests whether `a` is greater than or equal to `b`.
5719#### Accepts
5721`a` is a `@rh`, a half-precision float.
5723`b` is a `@rh`.
5725#### Produces
5727A `@rh`.
5729#### Source
5731```hoon
5732 ++ gte ~/ %gte
5733 |= [a=@rh b=@rh]
5734 ~_ leaf+"rh-fail"
5735 (gte:ma a b)
5736```
5738#### Examples
5740```
5741 > (gte:rh .~~1.24e4 .~~1.24e4)
5742 %.y
5744 > (gte:rh .~~2.24e4 .~~1.24e4)
5745 %.y
5747 > (gte:rh .~~1.24e4 .~~2.24e4)
5748 %.n
5749```
5751---
5753### `++gth:rh`
5755Tests whether `a` is greater than `b`.
5757#### Accepts
5759`a` is a `@rh`, a half-precision float.
5761`b` is a `@rh`.
5763#### Produces
5765A `@rh`.
5767#### Source
5769```hoon
5770 ++ gth ~/ %gth
5771 |= [a=@rh b=@rh]
5772 ~_ leaf+"rh-fail"
5773 (gth:ma a b)
5774```
5776#### Examples
5778```
5779 > (gth:rh .~~1.24e4 .~~1.244e4)
5780 %.n
5782 > (gth:rh .~~2.24e4 .~~1.24e4)
5783 %.y
5785 > (gth:rh .~~1.24e4 .~~2.24e4)
5786 %.n
5787```
5789---
5791### `++tos:rh`
5793`@rh` to `@rs`
5795Converts `@` from `@rh` to `@rs`.
5797#### Accepts
5799`a` is a `@rh`, a half-precision float.
5801#### Produces
5803A `@rs`, a single-precision float.
5805#### Source
5807```hoon
5808 ++ tos |= {a/@rh} (bit:rs (sea a))
5809```
5811#### Examples
5813```
5814 > (tos:rh .~~2.5e2)
5815 .2.5e2
5816```
5818---
5820### `++fos:rh`
5822`@rs` to `@rh`
5824Converts `@` from `@rs` to `@rh`.
5826#### Accepts
5828`a` is a `@rs`, a single-precision float.
5830#### Produces
5832A `@rh`, a half-precision float.
5834#### Source
5836```hoon
5837 ++ fos |= {a/@rs} (bit (sea:rs a))
5838```
5840#### Examples
5842```
5843 > (fos:rh .2.5e2)
5844 .~~2.5e2
5845```
5847---
5849### `++sun:rh`
5851Unsigned integer to `@rh`
5853Converts `@` from an unsigned integer to `@rh`.
5855#### Accepts
5857`a` is a `@u`, an unsigned integer.
5859#### Produces
5861A `@rh`, a half-precision float.
5863#### Source
5865```hoon
5866 ++ sun |= [a=@u] ^- @rh (sun:ma a)
5867```
5869#### Examples
5871```
5872 > (sun:rh 205)
5873 .~~2.05e2
5874```
5876---
5878### `++san:rh`
5880Signed integer to `@rh`
5882Converts `@` from a signed integer to `@rh`.
5884#### Accepts
5886`a` is a `@s`, a signed integer.
5888#### Produces
5890A `@rh`, a half-precision float.
5892#### Source
5894```hoon
5895 ++ san |= [a=@s] ^- @rh (san:ma a)
5896```
5898#### Examples
5900```
5901 > (san:rh -205)
5902 .~~-2.05e2
5903```
5905---
5907### `++sig:rh`
5909Get sign
5911Produces the sign of `a`.
5913#### Accepts
5915`a` is a `@rh`, a half-precision float.
5917#### Produces
5919A `flag`.
5921#### Source
5923```hoon
5924 ++ sig |= [a=@rh] ^- ? (sig:ma a)
5925```
5927#### Examples
5929```
5930 > (sig:rh .~~-2.05e2)
5931 %.n
5932```
5934---
5936### `++exp:rh`
5938Get exponent
5940Gets the exponent of `a`.
5942#### Accepts
5944`a` is a `@rh`, a half-precision float.
5946#### Produces
5948A `@s`, a signed integer.
5950#### Source
5952```hoon
5953 ++ exp |= [a=@rh] ^- @s (exp:ma a)
5954```
5956#### Examples
5958```
5959 > (exp:rh .~~-2.05e2)
5960 --7
5961```
5963---
5965### `++toi:rh`
5967Round to integer
5969Rounds `a` to the nearest integer.
5971#### Accepts
5973`a` is a `@rh`, a half-precision float.
5975#### Produces
5977A `unit` of `@s`.
5979#### Source
5981```hoon
5982 ++ toi |= [a=@rh] ^- (unit @s) (toi:ma a)
5983```
5985#### Examples
5987```
5988 > (toi:rh .~~-2.085e2)
5989 [~ u=-208]
5991 > (toi:rh .~~-2.08e2)
5992 [~ u=-208]
5993```
5995---
5997### `++drg:rh`
5999`@rh` to decimal float
6001Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
6002accurate results for rounded floats.
6004#### Accepts
6006`a` is a `@rh`, a half-precision float.
6008#### Produces
6010A `dn`.
6012#### Source
6014```hoon
6015 ++ drg |= [a=@rh] ^- dn (drg:ma a)
6016```
6018#### Examples
6020```
6021 > (drg:rh .~~-2.085e2)
6022 [%d s=%.n e=-1 a=2.085]
6024 > (drg:rh .~~-2.08e2)
6025 [%d s=%.n e=--0 a=208]
6026```
6028---
6030### `++grd:rh`
6032Decimal float to `@rh`
6034Converts `a` from `dn` to `@rh`.
6036#### Accepts
6038`a` is `dn`.
6040`a` is a `@rh`.
6042#### Produces
6044A `@rh`, a a half-precision float.
6046#### Source
6048```hoon
6049 ++ grd |= [a=dn] ^- @rh (grd:ma a)
6050 --
6051```
6053#### Examples
6055```
6056 > (grd:rh [%d s=%.n e=--0 a=343])
6057 .~~-3.43e2
6058```
6060---