on 4fdc19d help sign in
1518 lines 20 kB history raw
1+++
2title = "2c: Bit Arithmetic"
3weight = 6
4template = "doc.html"
5+++
7## `++bex`
9Binary exponent
11Computes the result of `2^a`, where `a` is a block size (see [$bloq](/docs/hoon/reference/stdlib/1c#bloq)), producing an atom.
13#### Accepts
15`a` is an `bloq`.
17#### Produces
19An atom.
21#### Source
23```hoon
24++ bex
25 ~/ %bex
26 |= a=bloq
27 ^- @
28 ?: =(0 a) 1
29 (mul 2 $(a (dec a)))
30```
32#### Examples
34```
35> (bex 4)
3616
37```
39```
40> (bex (add 19 1))
411.048.576
42```
44```
45> (bex 0)
47```
49---
51## `++can`
53Assemble
55Produces an atom from a list `b` of length-value pairs `p` and `q`,
56where `p` is the length in blocks of size `a`, and `q` is an atomic
57value.
59#### Accepts
61`a` is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq)).
63`b` is a `list` of length-value pairs, `p` and `q`:
65- `p` is a [step](/docs/hoon/reference/stdlib/1c/#step).
66- `q` is a `@`.
68#### Produces
70An atom.
72#### Source
74```hoon
75++ can
76 ~/ %can
77 |= [a=bloq b=(list [p=step q=@])]
78 ^- @
79 ?~ b 0
80 (add (end [a p.i.b] q.i.b) (lsh [a p.i.b] $(b t.b)))
81```
83#### Examples
85```
86> `@ub`21 :: @ub is the binary aura
870b1.0101
88```
90```
91> `@ub`(can 3 ~[[1 21]])
920b1.0101
93```
95```
96> `@ub`(can 3 ~[[1 1]])
970b1
98```
100```
101> `@ub`(can 0 ~[[1 255]])
1020b1
103```
105```
106> `@ux`(can 3 [3 0xc1] [1 0xa] ~) :: @ux is the hexadecimal aura
1070xa00.00c1
108```
110```
111> `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~)
1120x23.0a00.00c1
113```
115```
116> `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~)
1170x23.000a.0000.0000.00c1
118```
120```
121> `@ux`(can 3 ~[[1 'a'] [2 'bc']])
1220x63.6261
123```
125---
127## `++cat`
129Concatenate
131Concatenates two atoms, `b` and `c`, according to block size `a`, producing an
132atom.
134#### Accepts
136`a` is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq)).
138`b` is an atom.
140`c` is an atom.
142#### Produces
144An atom.
146#### Source
148```hoon
149++ cat
150 ~/ %cat
151 |= [a=bloq b=@ c=@]
152 (add (lsh [a (met a b)] c) b)
153```
155#### Examples
157```
158> `@ub`(cat 3 1 0) :: @ub is the binary aura
1590b1
160> `@ub`(cat 0 1 1)
1610b11
162> `@ub`(cat 0 2 1)
1630b110
164> `@ub`(cat 2 1 1)
1650b1.0001
166```
168```
169> `@ub`256
1700b1.0000.0000
171> `@ub`255
1720b1111.1111
173> `@ub`(cat 3 256 255)
1740b1111.1111.0000.0001.0000.0000
175> `@ub`(cat 2 256 255)
1760b1111.1111.0001.0000.0000
177> (cat 3 256 255)
17816.711.936
179> (cat 2 256 255)
1801.044.736
181```
183---
185## `++cut`
187Slice
189Slices `c` blocks of size `a` that are positioned `b` blocks from the end of
190`d`. That slice is produced as an atom.
192#### Accepts
194`a` is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c)).
196`[b c]` where:
198- `b` is a [step](/docs/hoon/reference/stdlib/1c#step).
199- `c` is a [step](/docs/hoon/reference/stdlib/1c#step).
201`d` is an atom.
203#### Produces
205An atom.
207#### Source
209```hoon
210++ cut
211 ~/ %cut
212 |= [a=bloq [b=step c=step] d=@]
213 (end [a c] (rsh [a b] d))
214```
216#### Examples
218```
219> (cut 0 [1 1] 2)
221> (cut 0 [2 1] 4)
223```
225```
226> `@t`(cut 3 [0 3] 'abcdefgh') :: @t is the cord aura
227'abc'
228> `@t`(cut 3 [1 3] 'abcdefgh')
229'bcd'
230```
232```
233> `@ub`(cut 0 [0 3] 0b1111.0000.1101) :: @ub is the binary aura
2340b101
235> `@ub`(cut 0 [0 6] 0b1111.0000.1101)
2360b1101
237> `@ub`(cut 0 [4 6] 0b1111.0000.1101)
2380b11.0000
239> `@ub`(cut 0 [3 6] 0b1111.0000.1101)
2400b10.0001
241```
243---
245## `++end`
247Tail
249Produces an atom by taking the last `step` blocks of size `bloq` from `b`.
251#### Accepts
253`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
254which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
255with optional block count.
257`b` is an atom.
259#### Produces
261An atom.
263#### Source
265```hoon
266++ end
267 ~/ %end
268 |= [a=bite b=@]
269 =/ [=bloq =step] ?^(a a [a *step])
270 (mod b (bex (mul (bex bloq) step)))
271```
273#### Examples
275```
276> (end [2 2] 255)
277255
278> (end [3 1] 255)
279255
280> (end 3 255)
281255
282> (end 3 256)
284```
286```
287> `@ub`12 :: @ub is the binary aura
2880b1100
289> `@ub`(end [0 3] 12)
2900b100
291> (end [0 3] 12)
293> `@ub`(end [1 3] 12)
2940b1100
295> (end [1 3] 12)
29612
297```
299```
300> `@ux`'abc' :: @ux is the hexademical aura
3010x63.6261
302> `@ux`(end [3 2] 'abc')
3030x6261
304> `@t`(end [3 2] 'abc') :: @t is the cord aura
305'ab'
306```
308---
310## `++fil`
312Fill bloqstream
314Produces an atom by repeating `c` for `b` blocks of size `a`.
316#### Accepts
318`a` is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq)).
320`b` is a [step](/docs/hoon/reference/stdlib/1c#step).
322`c` is an atom.
324#### Produces
326An atom.
328#### Source
330```hoon
331++ fil
332 ~/ %fil
333 |= [a=bloq b=step c=@]
334 =| n=@ud
335 =. c (end a c)
336 =/ d c
337 |- ^- @
338 ?: =(n b)
339 (rsh a d)
340 $(d (add c (lsh a d)), n +(n))
341```
343#### Examples
345```
346> `@t`(fil 3 5 %a) :: @t is the cord (string) aura
347'aaaaa'
348```
350```
351> `@t`(fil 5 10 %ceeb)
352'ceebceebceebceebceebceebceebceebceebceeb'
353```
355```
356> `@t`(fil 4 10 'eced')
357'ecececececececececec'
358```
360```
361> `@tas`(fil 4 10 %bf) :: @tas is the term aura
362%bfbfbfbfbfbfbfbfbfbf
363```
365```
366> `@ub`(fil 2 6 1) :: @ub is the binary aura
3670b1.0001.0001.0001.0001.0001
368```
370---
372## `++lsh`
374Left-shift
376Produces an atom by left-shifting `b` by `step` blocks of size `bloq`.
378#### Accepts
380`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
381which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
382with optional block count.
384`b` is an atom.
386#### Produces
388An atom.
390#### Source
392```hoon
393++ lsh
394 ~/ %lsh
395 |= [a=bite b=@]
396 =/ [=bloq =step] ?^(a a [a *step])
397 (mul b (bex (mul (bex bloq) step)))
398```
400#### Examples
402```
403> `@ub`1 :: @ub is the binary aura
4040b1
405> `@ub`(lsh [0 1] 1)
4060b10
407> (lsh [0 1] 1)
409> (lsh 0 1)
411```
413```
414> `@ub`255
4150b1111.1111
416> `@ub`(lsh [3 1] 255)
4170b1111.1111.0000.0000
418> (lsh [3 1] 255)
41965.280
420```
422---
424## `++met`
426Measure
428Computes the number of blocks of size `a` in `b`, producing an atom.
430#### Accepts
432`a` is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c/bloq)).
434`b` is an atom.
436#### Source
438```hoon
439++ met
440 ~/ %met
441 |= [a=bloq b=@]
442 ^- @
443 =+ c=0
444 |-
445 ?: =(0 b) c
446 $(b (rsh a b), c +(c))
447```
449#### Examples
451```
452> (met 0 1)
454> (met 0 2)
456```
458```
459> (met 3 255)
461> (met 3 256)
463```
465```
466> (met 3 'abcde')
468```
470---
472## `++rap`
474Assemble non-zero
476Concatenates a list of atoms `b` using block size `a`, producing an atom.
478#### Accepts
480`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
482`b` is a `list` of atoms.
484#### Produces
486An atom.
488#### Source
490```hoon
491++ rap
492 ~/ %rap
493 |= [a=bloq b=(list @)]
494 ^- @
495 ?~ b 0
496 (cat a i.b $(b t.b))
497```
499#### Examples
501```
502> `@ub`(rap 2 [1 2 3 4 ~]) :: @ub is the binary aura
5030b100.0011.0010.0001
504> `@ub`(rap 1 [1 2 3 4 ~])
5050b1.0011.1001
506```
508```
509> (rap 0 [0 0 0 ~])
511> (rap 0 [1 0 1 ~])
513```
515```
516> `@ub`3
5170b11
518> (rap 0 [0 1 0 0 1 2 ~])
51911
520> (rap 0 [1 1 2 ~])
52111
522> `@ub`11
5230b1011
524```
526#### Discussion
528Any element of the value `0` is not included in concatenation.
530---
532## `++rep`
534Assemble single
536Produces an atom by assembling a list of atoms `b` using block size `a`.
538#### Accepts
540`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
541which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
542with optional block count.
544`b` is a list of atoms.
546#### Produces
548An atom.
550#### Source
552```hoon
553++ rep
554 ~/ %rep
555 |= [a=bite b=(list @)]
556 =/ [=bloq =step] ?^(a a [a *step])
557 =| i=@ud
558 |- ^- @
559 ?~ b 0
560 %+ add $(i +(i), b t.b)
561 (lsh [bloq (mul step i)] (end [bloq step] i.b))
562```
564#### Examples
566```
567> `@ub`(rep 2 [1 2 3 4 ~]) :: @ub is the binary aura
5680b100.0011.0010.0001
569```
571```
572> (rep 0 [0 0 1 ~])
574> (rep 0 [0 0 0 1 ~])
576```
578```
579> `@ub`(rep 0 [0 0 0 1 ~])
5800b1000
581> `@ub`8
5820b1000
583```
585```
586> `@ub`(rep 0 [1 0 1 0 ~])
5870b101
588> `@ub`(rep 0 [1 2 3 4 ~])
5890b101
590```
592```
593> (rep 0 [0 1 0 1 ~])
59410
595> (rep 0 [1 0 1 0 1 ~])
59621
597> `@ub`21
5980b10.1010
599```
601```
602> `@ub`(rep 3 [12 166 8 34 ~])
6030b10.0010.0000.1000.1010.0110.0000.1100
604```
606```
607> `*`"abcd"
608[97 98 99 100 0]
609> `@t`(rep 3 "abcd") :: @t is the text aura
610'abcd'
611```
613---
615## `++rev`
617Reverses block order, accounting for leading zeroes.
619Produces an atom from the bits of `dat` in reverse order according to a block
620size `boz` and a size `len`.
622If the total size is less than the length of `dat`, then only the first
623bits of `dat` up to the total size will be taken and reversed. If the total size
624is longer, trailing zeroes will be added.
626#### Accepts
628`boz` is a block size with optional block count (see
629[`$bloq`](/docs/hoon/reference/stdlib/1c#bloq)).
631`len` is a `@ud` of the number of blocks of size `boz` to be reversed.
633`dat` is an atom.
635#### Produces
637An atom.
639#### Source
641```hoon
642++ rev
643 ~/ %rev
644 |= [boz=bloq len=@ud dat=@]
645 ^- @
646 =. dat (end [boz len] dat)
647 %+ lsh
648 [boz (sub len (met boz dat))]
649 (swp boz dat)
650```
652#### Examples
654```
655> =a 0b1111.0000.1111.1010.0011
656> `@ub`(rev 0 20 a)
6570b1100.0101.1111.0000.1111
658> `@ub`(rev 0 12 a)
6590b1100.0101.1111
660> `@ub`(rev 2 5 a)
6610b11.1010.1111.0000.1111
662> `@ub`(rev 2 4 a)
6630b11.1010.1111.0000
664> `@ub`(rev 2 6 a)
6650b11.1010.1111.0000.1111.0000
666```
668```
669> (rev 1 10 1.000)
670179.200
671> (rev 2 5 1.000)
672582.400
673> (rev 1 5 1.000)
674175
675```
677---
679## `++rip`
681Disassemble
683Produces a list of atoms from the bits of `b` using block size `a`.
685#### Accepts
687`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
688which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
689with optional block count.
691`b` is an atom.
693#### Produces
695A list of atoms.
697#### Source
699```hoon
700++ rip
701 ~/ %rip
702 |= [a=bite b=@]
703 ^- (list @)
704 ?: =(0 b) ~
705 [(end a b) $(b (rsh a b))]
706```
708#### Examples
710```
711> `@ub`155 :: @ub is the binary aura
7120b1001.1011
713> (rip 0 155)
714~[1 1 0 1 1 0 0 1]
715> (rip 2 155)
716~[11 9]
717```
719```
720> (rip 0 11)
721~[1 1 0 1]
722> (rip 1 155)
723~[3 2 1 2]
724```
726```
727> `@ub`256
7280b1.0000.0000
729> (rip 0 256)
730~[0 0 0 0 0 0 0 0 1]
731> (rip 2 256)
732~[0 0 1]
733> (rip 3 256)
734~[0 1]
735```
737```
738> `tape`(rip 3 'abcd')
739"abcd"
740```
742---
744## `++rsh`
746Right-shift
748Right-shifts `b` by `step` blocks of size `bloq`, producing an atom.
750#### Accepts
752`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
753which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
754with optional block count.
756`b` is an atom.
758#### Produces
760An atom.
762#### Source
764```hoon
765++ rsh
766 ~/ %rsh
767 |= [a=bite b=@]
768 =/ [=bloq =step] ?^(a a [a *step])
769 (div b (bex (mul (bex bloq) step)))
770```
772#### Examples
774```
775> `@ub`145 :: @ub is the binary aura
7760b1001.0001
777> `@ub`(rsh [1 1] 145)
7780b10.0100
779> (rsh [1 1] 145)
78036
781> (rsh 1 145)
78236
783> `@ub`(rsh [2 1] 145)
7840b1001
785> (rsh [2 1] 145)
787```
789```
790> `@ub`10
7910b1010
792> `@ub`(rsh [0 1] 10)
7930b101
794> (rsh [0 1] 10)
796```
798```
799> `@ux`'abc'
8000x63.6261
801> `@t`(rsh [3 1] 'abc')
802'bc'
803> `@ux`(rsh [3 1] 'abc')
8040x6362
805```
807---
809## `++run`
811`++turn` into atom.
813Disassembles atom `b` into slices specified by `a`, applies `c` to each slice,
814and reassembles the results back into an atom.
816#### Accepts
818`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
819which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
820with optional block count.
822`b` is an atom.
824`c` is a gate that accepts an atom and produces an atom.
826#### Produces
828An atom.
830#### Source
832```hoon
833++ run
834 ~/ %run
835 |= [a=bite b=@ c=$-(@ @)]
836 (rep a (turn (rip a b) c))
837```
839#### Examples
841```
842 > `@ux`65.535 :: @ux is the hexadecimal aura
843 0xffff
844 > `@ux`(run 2 65.535 dec) :: dec is the decrement gate
845 0xeeee
846```
848---
850## `++rut`
852`++turn` into list.
854Disassembles atom `b` into slices specified by `a`, applies `c` to each slice,
855and assembles the results back into a.
857#### Accepts
859`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
860which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
861with optional block count.
863`b` is an atom.
865`c` is a gate that accepts an atom.
867#### Produces
869A list.
871#### Source
873```hoon
874++ rut
875 ~/ %rut
876 |* [a=bite b=@ c=$-(@ *)]
877 (turn (rip a b) c)
878```
880#### Examples
882```
883> `@ux`65.535 :: @ux is the hexadecimal aura
8840xffff
885> `(list @ux)`(rut 2 65.535 dec) :: dec is the decrement gate
886~[0xe 0xe 0xe 0xe]
887```
889---
891## `++sew`
893Stitch one atom into another
895Replace `c` blocks of size `a` at offset `b` of atom `e` with `c` blocks of size `a` from atom `d`.
897That is, take `(end [a c] d)` from `d` and overwrite the `(cut a [b c] e)` part of `e`.
899Or in simpler terms, take from the start of `d` and replace some part of `e` with it.
901#### Accepts
903`a` is a [$bloq](/docs/hoon/reference/stdlib/1c#bite) (block size).
905`[b c d]` where:
907- `b` is a [step](/docs/hoon/reference/stdlib/1c#step) specifying the number of `bloq`s to offset.
908- `b` is a [step](/docs/hoon/reference/stdlib/1c#step) specifying the number of `bloq`s to replace.
909- `d` is the donor atom.
911`e` is the recipient atom.
913#### Produces
915An atom.
917#### Source
919```hoon
920++ sew
921 ~/ %sew
922 |= [a=bloq [b=step c=step d=@] e=@]
923 ^- @
924 %+ add
925 (can a b^e c^d ~)
926 =/ f [a (add b c)]
927 (lsh f (rsh f e))
928```
930#### Examples
932```
933> `@t`(sew 3 [0 0 'XXXX'] 'OOOO')
934'OOOO'
935> `@t`(sew 3 [0 1 'XXXX'] 'OOOO')
936'XOOO'
937> `@t`(sew 3 [2 1 'XXXX'] 'OOOO')
938'OOXO'
939> `@t`(sew 3 [2 2 'XXXX'] 'OOOO')
940'OOXX'
941> `@t`(sew 3 [0 4 'XXXX'] 'OOOO')
942'XXXX'
943```
945---
947## `++swp`
949Reverse block order
951Switches little-endian to big-endian and vice versa: produces an atom by
952reversing the block order of `b` using block size `a`.
954#### Accepts
956`a` is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq)).
958`b` is an atom.
960#### Produces
962An atom
964#### Source
966```hoon
967++ swp
968 ~/ %swp
969 |= [a=bloq b=@]
970 (rep a (flop (rip a b)))
971```
973#### Examples
975```
976> `@ub`24 :: @ub is the binary aura
9770b1.1000
978> (swp 0 24)
980> `@ub`3
9810b11
982```
984```
985> (swp 0 0)
987> (swp 0 128)
989```
991---
993## `++xeb`
995Binary logarithm
997Computes the base-2 logarithm of `a`, producing an atom.
999#### Accepts
1001`a` is an atom.
1003#### Produces
1005An atom.
1007#### Source
1009```hoon
1010++ xeb
1011 ~/ %xeb
1012 |= a=@
1013 ^- @
1014 (met 0 a)
1015```
1017#### Examples
1019```
1020> (xeb 31)
1022```
1024```
1025> (xeb 32)
1027```
1029```
1030> (xeb 49)
1032```
1034```
1035> (xeb 0)
1037```
1039```
1040> (xeb 1)
1042```
1044```
1045> (xeb 2)
1047```
1049---
1051## `++fe`
1053Modulo bloq
1055Core that contains arms for `bloq` and modular integer operations.
1057#### Accepts
1059`a` is a `bloq`.
1061#### Source
1063```hoon
1064 |_ a=bloq
1065```
1067---
1069### `++dif:fe`
1071Produces the difference between two atoms in the modular basis
1072representation.
1074#### Accepts
1076`a` is a `bloq` (and is the sample of the parent core).
1078`b` is an atom.
1080`c` is an atom.
1082#### Produces
1084A `@s`.
1086#### Source
1088```hoon
1089 ++ dif
1090 |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c))))
1091```
1093#### Examples
1095```
1096> (~(dif fe 3) 63 64)
1097255
1098> (~(dif fe 3) 5 10)
1099251
1100> (~(dif fe 3) 0 1)
1101255
1102```
1104```
1105> (~(dif fe 0) 9 10)
1107> (~(dif fe 0) 9 11)
1109> (~(dif fe 0) 9 12)
1111```
1113```
1114> (~(dif fe 2) 9 12)
1116> (~(dif fe 2) 63 64)
1118```
1120---
1122### `++inv:fe`
1124Inverse
1126Inverts the order of the modular field.
1128#### Accepts
1130`a` is a `bloq` (and is the sample of the parent core).
1132`b` is a `bloq`. (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
1134#### Produces
1136An atom.
1138#### Source
1140```hoon
1141++ inv |=(b=@ (sub (dec out) (sit b)))
1142```
1144#### Examples
1146```
1147> (~(inv fe 3) 255)
1149> (~(inv fe 3) 256)
1150255
1151```
1153```
1154> (~(inv fe 3) 0)
1155255
1156> (~(inv fe 3) 1)
1157254
1158> (~(inv fe 3) 2)
1159253
1160```
1162```
1163> (~(inv fe 3) 55)
1164200
1165```
1167---
1169### `++net:fe`
1171Flip endianness
1173Reverses bytes within a block.
1175#### Accepts
1177`a` is a `bloq` (and the sample of the parent core).
1179`b` is a `bloq`. (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
1181#### Produces
1183An atom.
1185#### Source
1187```hoon
1188++ net |= b=@ ^- @
1189 => .(b (sit b))
1190 ?: (lte a 3)
1192 =+ c=(dec a)
1193 %+ con
1194 (lsh c $(a c, b (cut c [0 1] b)))
1195 $(a c, b (cut c [1 1] b))
1196```
1198#### Examples
1200```
1201> (~(net fe 3) 64)
1203> (~(net fe 3) 128)
1204128
1205> (~(net fe 3) 255)
1206255
1207> (~(net fe 3) 256)
1209> (~(net fe 3) 257)
1211```
1213```
1214> (~(net fe 3) 500)
1215244
1216> (~(net fe 3) 511)
1217255
1218> (~(net fe 3) 512)
1220> (~(net fe 3) 513)
1222```
1224```
1225> (~(net fe 3) 0)
1227> (~(net fe 3) 1)
1229> (~(net fe 0) 1)
1231> (~(net fe 0) 2)
1233> (~(net fe 0) 3)
1235```
1237```
1238> (~(net fe 6) 1)
123972.057.594.037.927.936
1240> (~(net fe 6) 2)
1241144.115.188.075.855.872
1242> (~(net fe 6) 3)
1243216.172.782.113.783.808
1244> (~(net fe 6) 4)
1245288.230.376.151.711.744
1246> (~(net fe 6) 5)
1247360.287.970.189.639.680
1248```
1250---
1252### `++out:fe`
1254Max integer value
1256Produces the maximum integer value that the current block can store; `2^a^a`.
1258#### Accepts
1260`a` is a `bloq` (and is the sample of the parent core).
1262#### Produces
1264An atom.
1266#### Source
1268```hoon
1269++ out (bex (bex a))
1270```
1272#### Examples
1274```
1275> ~(out fe 0)
1277> ~(out fe 1)
1279> ~(out fe 2)
1281> ~(out fe 3)
1282256
1283> ~(out fe 4)
128465.536
1285```
1287```
1288> ~(out fe 10)
1289\/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.273\/
1290 .430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113.879.87
1291 1.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767.893.424.8
1292 65.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838.150.682.342.
1293 462.881.473.913.110.540.827.237.163.350.510.684.586.298.239.947.245.938.479
1294 .716.304.835.356.329.624.224.137.216
1295\/ \/
1296```
1298---
1300### `++rol:fe`
1302Roll left
1304Rolls `d` to the left by `c` `b`-sized blocks.
1306#### Accepts
1308`a` is a `bloq` (and is the sample of the parent core).
1310`b` is a `bloq`.
1312`c` is an atom.
1314`d` is an atom.
1316#### Produces
1318An atom.
1320#### Source
1322```hoon
1323++ rol |= [b=bloq c=@ d=@] ^- @
1324 =+ e=(sit d)
1325 =+ f=(bex (sub a b))
1326 =+ g=(mod c f)
1327 (sit (con (lsh [b g] e) (rsh [b (sub f g)] e)))
1328```
1330#### Examples
1332```
1333> `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213)
13340x1213.0000.abac.dedf
1336> `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213)
13370xdedf.1213.0000.abac
1338```
1340```
1341> `@t`(~(rol fe 5) 3 1 'dfgh')
1342'hdfg'
1344> `@t`(~(rol fe 5) 3 2 'dfgh')
1345'ghdf'
1347> `@t`(~(rol fe 5) 3 0 'dfgh')
1348'dfgh'
1349```
1351---
1353### `++ror:fe`
1355Roll right
1357Rolls `d` to the right by `c` `b`-sized blocks.
1359#### Accepts
1361`a` is a `bloq` (and is the sample of the parent core).
1363`b` is a `bloq`.
1365`c` is an atom.
1367`d` is an atom.
1369#### Produces
1371An atom.
1373#### Source
1375```hoon
1376++ ror |= [b=bloq c=@ d=@] ^- @
1377 =+ e=(sit d)
1378 =+ f=(bex (sub a b))
1379 =+ g=(mod c f)
1380 (sit (con (rsh [b g] e) (lsh [b (sub f g)] e)))
1381```
1383#### Examples
1385```
1386> `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213)
13870x1213.0000.abac.dedf
1389> `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213)
13900xacde.df12.1300.00ab
1392> `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213)
13930xdf12.1300.00ab.acde
1394```
1396```
1397> `@t`(~(rol fe 5) 3 0 'hijk')
1398'hijk'
1400> `@t`(~(rol fe 5) 3 1 'hijk')
1401'khij'
1403> `@t`(~(rol fe 5) 3 2 'hijk')
1404'jkhi'
1405```
1407---
1409### `++sum:fe`
1411Sum
1413Sums two numbers in this modular field.
1415#### Accepts
1417`a` is a `bloq` (and is the sample of the parent core).
1419`b` is an atom.
1421`c` is an atom.
1423#### Produces
1425An atom.
1427#### Source
1429```hoon
1430++ sum |=([b=@ c=@] (sit (add b c)))
1431```
1433#### Examples
1435```
1436> (~(sum fe 3) 10 250)
1438```
1440```
1441> (~(sum fe 0) 0 1)
1443> (~(sum fe 0) 0 2)
1445```
1447```
1448> (~(sum fe 2) 14 2)
1450> (~(sum fe 2) 14 3)
1452```
1454```
1455> (~(sum fe 4) 10.000 256)
145610.256
1457> (~(sum fe 4) 10.000 100.000)
145844.464
1459```
1461---
1463### `++sit:fe`
1465Enforce modulo
1467Produces an atom in the current modular block representation.
1469#### Accepts
1471`a` is a `bloq` (and is the sample of the parent core).
1473`b` is an atom.
1475#### Produces
1477An atom.
1479#### Source
1481```hoon
1482++ sit |=(b=@ (end a b))
1483```
1485#### Examples
1487```
1488> (~(sit fe 3) 255)
1489255
1490> (~(sit fe 3) 256)
1492> (~(sit fe 3) 257)
1494```
1496```
1497> (~(sit fe 2) 257)
1499> (~(sit fe 2) 10.000)
1501> (~(sit fe 2) 100)
1503> (~(sit fe 2) 19)
1505> (~(sit fe 2) 17)
1507```
1509```
1510> (~(sit fe 0) 17)
1512> (~(sit fe 0) 0)
1514> (~(sit fe 0) 1)
1516```
1518---