on d7dad8b help sign in
1442 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`, producing an atom.
13#### Accepts
15`a` is an atom.
17#### Produces
19An atom.
21#### Source
23```hoon
24 ++ bex
25 ~/ %bex
26 |= a=@
27 ^- @
28 ?: =(0 a) 1
29 (mul 2 $(a (dec a)))
30```
32#### Examples
34```
35 > (bex 4)
36 16
38 > (bex (add 19 1))
39 1.048.576
41 > (bex 0)
42 1
43```
45---
47### `++can`
49Assemble
51Produces an atom from a list `b` of length-value pairs `p` and `q`,
52where `p` is the length in blocks of size `a`, and `q` is an atomic
53value.
55#### Accepts
57`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
59`b` is a `list` of length-value pairs, `p` and `q`.
61#### Produces
63An atom.
65#### Source
67```hoon
68 ++ can
69 ~/ %can
70 |= [a=bloq b=(list [p=@ q=@])]
71 ^- @
72 ?~ b 0
73 (add (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b)))
74```
76#### Examples
78```
79 > `@ub`21 :: @ub is the binary aura
80 0b1.0101
82 > `@ub`(can 3 ~[[1 21]])
83 0b1.0101
85 > `@ub`(can 3 ~[[1 1]])
86 0b1
88 > `@ub`(can 0 ~[[1 255]])
89 0b1
91 > `@ux`(can 3 [3 0xc1] [1 0xa] ~) :: @ux is the hexadecimal aura
92 0xa00.00c1
94 > `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~)
95 0x23.0a00.00c1
97 > `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~)
98 0x23.000a.0000.0000.00c1
100 > `@ux`(can 3 ~[[1 'a'] [2 'bc']])
101 0x63.6261
102```
104---
106### `++cat`
108Concatenate
110Concatenates two atoms, `b` and `c`, according to block size `a`, producing an
111atom.
113#### Accepts
115`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
117`b` is an atom.
119`c` is an atom.
121#### Produces
123An atom.
125#### Source
127```hoon
128 ++ cat
129 ~/ %cat
130 |= [a=bloq b=@ c=@]
131 (add (lsh a (met a b) c) b)
132```
134#### Examples
136```
137 > `@ub`(cat 3 1 0) :: @ub is the binary aura
138 0b1
140 > `@ub`(cat 0 1 1)
141 0b11
143 > `@ub`(cat 0 2 1)
144 0b110
146 > `@ub`(cat 2 1 1)
147 0b1.0001
149 > `@ub`256
150 0b1.0000.0000
152 > `@ub`255
153 0b1111.1111
155 > `@ub`(cat 3 256 255)
156 0b1111.1111.0000.0001.0000.0000
158 > `@ub`(cat 2 256 255)
159 0b1111.1111.0001.0000.0000
161 > (cat 3 256 255)
162 16.711.936
164 > (cat 2 256 255)
165 1.044.736
166```
168---
170### `++cut`
172Slice
174Slices `c` blocks of size `a` that are positioned `b` blocks from the end of
175`d`. That slice is produced as an atom.
177#### Accepts
179`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
181`b` is an atom.
183`c` is an atom.
185`d` is an atom.
187#### Produces
189An atom.
191#### Source
193```hoon
194 ++ cut
195 ~/ %cut
196 |= [a=bloq [b=@u c=@u] d=@]
197 (end a c (rsh a b d))
198```
200#### Examples
202```
203 > (cut 0 [1 1] 2)
204 1
206 > (cut 0 [2 1] 4)
207 1
209 > `@t`(cut 3 [0 3] 'abcdefgh')
210 'abc'
212 > `@t`(cut 3 [1 3] 'abcdefgh') :: @t is the cord aura
213 'bcd'
215 > `@ub`(cut 0 [0 3] 0b1111.0000.1101) :: @ub is the binary aura
216 0b101
218 > `@ub`(cut 0 [0 6] 0b1111.0000.1101)
219 0b1101
221 > `@ub`(cut 0 [4 6] 0b1111.0000.1101)
222 0b11.0000
224 > `@ub`(cut 0 [3 6] 0b1111.0000.1101)
225 0b10.0001
226```
228---
230### `++end`
232Tail
234Produces an atom by taking the last `step` blocks of size `bloq` from `b`.
236#### Accepts
238`a` is an atom slice specifier (see [`++bite`](/docs/hoon/reference/stdlib/1c#bite)),
239which is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c#bloq))
240with optional block count.
242`b` is an atom.
244#### Produces
246An atom.
248#### Source
250```hoon
251 ++ end
252 ~/ %end
253 |= [a=bite b=@]
254 =/ [=bloq =step] ?^(a a [a *step])
255 (mod b (bex (mul (bex bloq) step)))
256```
258#### Examples
260```
261 > (end [2 2] 255)
262 255
264 > (end [3 1] 255)
265 255
267 > (end 3 255)
268 255
270 > (end 3 256)
271 0
273 > `@ub`12 :: @ub is the binary aura
274 0b1100
276 > `@ub`(end [0 3] 12)
277 0b100
279 > (end [0 3] 12)
280 4
282 > `@ub`(end [1 3] 12)
283 0b1100
285 > (end [1 3] 12)
286 12
288 > `@ux`'abc' :: @ux is the hexademical aura
289 0x63.6261
291 > `@ux`(end [3 2] 'abc')
292 0x6261
294 > `@t`(end [3 2] 'abc') :: @t is the cord aura
295 'ab'
296```
298---
300### `++fil`
302Fill bloqstream
304Produces an atom by repeating `c` for `b` blocks of size `a`.
306#### Accepts
308`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
310`b` is an atom.
312`c` is an atom.
314#### Produces
316An atom.
318#### Source
320```hoon
321 ++ fil
322 |= [a=bloq b=@u c=@]
323 =+ n=0
324 =+ d=c
325 |- ^- @
326 ?: =(n b)
327 (rsh a 1 d)
328 $(d (add c (lsh a 1 d)), n +(n))
329```
331#### Examples
333```
334 > `@t`(fil 3 5 %a) :: @t is the cord (string) aura
335 'aaaaa'
337 > `@t`(fil 5 10 %ceeb)
338 'ceebceebceebceebceebceebceebceebceebceeb'
340 > `@t`(fil 4 10 %eced)
341 'ʇʇʇʇʇʇʇʇʇʇed'
343 > `@tas`(fil 4 10 %bf) :: @tas is the term aura
344 %bfbfbfbfbfbfbfbfbfbf
346 > `@ub`(fil 2 6 1) :: @ub is the binary aura
347 0b1.0001.0001.0001.0001.0001
348```
350---
352### `++lsh`
354Left-shift
356Produces an atom by left-shifting `b` by `step` blocks of size `bloq`.
358#### Accepts
360`a` is an atom slice specifier (see [`++bite`](/docs/hoon/reference/stdlib/1c#bite)),
361which is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c#bloq))
362with optional block count.
364`b` is an atom.
366#### Produces
368An atom.
370#### Source
372```hoon
373 ++ lsh
374 ~/ %lsh
375 |= [a=bite b=@]
376 =/ [=bloq =step] ?^(a a [a *step])
377 (mul b (bex (mul (bex bloq) step)))
378```
380#### Examples
382```
383 > `@ub`1 :: @ub is the binary aura
384 0b1
386 > `@ub`(lsh [0 1] 1)
387 0b10
389 > (lsh [0 1] 1)
390 2
392 > (lsh 0 1)
393 2
395 > `@ub`255
396 0b1111.1111
398 > `@ub`(lsh [3 1] 255)
399 0b1111.1111.0000.0000
401 > (lsh [3 1] 255)
402 65.280
403```
405---
407### `++met`
409Measure
411Computes the number of blocks of size `a` in `b`, producing an atom.
413#### Accepts
415`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
417`b` is an atom.
419#### Source
421```hoon
422 ++ met
423 ~/ %met
424 |= [a=bloq b=@]
425 ^- @
426 =+ c=0
427 |-
428 ?: =(0 b) c
429 $(b (rsh a 1 b), c +(c))
430```
432#### Examples
434```
435 > (met 0 1)
436 1
438 > (met 0 2)
439 2
441 > (met 3 255)
442 1
444 > (met 3 256)
445 2
447 > (met 3 'abcde')
448 5
449```
451---
453### `++rap`
455Assemble non-zero
457Concatenates a list of atoms `b` using block size `a`, producing an atom.
459#### Accepts
461`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
463`b` is a `list` of atoms.
465#### Produces
467An atom.
469#### Source
471```hoon
472 ++ rap
473 ~/ %rap
474 |= [a=bloq b=(list @)]
475 ^- @
476 =+ ~
477 ?~ b 0
478 (cat a i.b $(b t.b))
479```
481#### Examples
483```
484 > `@ub`(rap 2 [1 2 3 4 ~]) :: @ub is the binary aura
485 0b100.0011.0010.0001
487 > `@ub`(rap 1 [1 2 3 4 ~])
488 0b1.0011.1001
490 > (rap 0 [0 0 0 ~])
491 0
493 > (rap 0 [1 0 1 ~])
494 3
496 > `@ub`3
497 0b11
499 > (rap 0 [0 1 0 0 1 2 ~])
500 11
502 > (rap 0 [1 1 2 ~])
503 11
505 > `@ub`11
506 0b1011
507```
509#### Discussion
511Any element of the value `0` is not included in concatenation.
513---
515### `++rep`
517Assemble single
519Produces an atom by assembling a list of atoms `b` using block size `a`.
521#### Accepts
523`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
524which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
525with optional block count.
527`b` is a list of atoms.
529#### Produces
531An atom.
533#### Source
535```hoon
536 ++ rep
537 ~/ %rep
538 |= [a=bite b=(list @)]
539 =/ [=bloq =step] ?^(a a [a *step])
540 =| i=@ud
541 |- ^- @
542 ?~ b 0
543 %+ add $(i +(i), b t.b)
544 (lsh [bloq (mul step i)] (end [bloq step] i.b))
545```
547#### Examples
549```
550 > `@ub`(rep 2 [1 2 3 4 ~]) :: @ub is the binary aura
551 0b100.0011.0010.0001
553 > (rep 0 [0 0 1 ~])
554 4
556 > (rep 0 [0 0 0 1 ~])
557 8
559 > `@ub`(rep 0 [0 0 0 1 ~])
560 0b1000
562 > `@ub`8
563 0b1000
565 > `@ub`(rep 0 [1 0 1 0 ~])
566 0b101
568 > `@ub`(rep 0 [1 2 3 4 ~])
569 0b101
571 > (rep 0 [0 1 0 1 ~])
572 10
574 > (rep 0 [1 0 1 0 1 ~])
575 21
577 > `@ub`21
578 0b10.1010
580 > `@ub`(rep 3 [12 166 8 34 ~])
581 0b10.0010.0000.1000.1010.0110.0000.1100
583 > `*`"abcd"
584 [97 98 99 100 0]
586 > `@t`(rep 3 "abcd") :: @t is the text aura
587 'abcd'
588```
590---
592### `++rev`
594Reverses block order, accounting for leading zeroes.
596Produces an atom from the bits of `dat` in reverse order according to a block
597size `boz` and a size `len`.
599If the total size is less than the length of `dat`, then only the first
600bits of `dat` up to the total size will be taken and reversed. If the total size
601is longer, trailing zeroes will be added.
603#### Accepts
605`boz` is a block size with optional block count (see
606[`$bloq`](/docs/hoon/reference/stdlib/1c#bloq)).
608`len` is a `@ud` of the number of blocks of size `boz` to be reversed.
610`dat` is an atom.
612#### Produces
614An atom.
616#### Source
618```hoon
619++ rev
620 ~/ %rev
621 |= [boz=bloq len=@ud dat=@]
622 ^- @
623 =. dat (end [boz len] dat)
624 %+ lsh
625 [boz (sub len (met boz dat))]
626 (swp boz dat)
627```
629#### Examples
631```
632> =a 0b1111.0000.1111.1010.0011
634> `@ub`(rev 0 20 a)
6350b1100.0101.1111.0000.1111
637> `@ub`(rev 0 12 a)
6380b1100.0101.1111
640> `@ub`(rev 2 5 a)
6410b11.1010.1111.0000.1111
643> `@ub`(rev 2 4 a)
6440b11.1010.1111.0000
646> `@ub`(rev 2 6 a)
6470b11.1010.1111.0000.1111.0000
649> (rev 1 10 1.000)
650179.200
652> (rev 2 5 1.000)
653582.400
655> (rev 1 5 1.000)
656175
657```
659---
661### `++rip`
663Disassemble
665Produces a list of atoms from the bits of `b` using block size `a`.
667#### Accepts
669`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
670which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
671with optional block count.
673`b` is an atom.
675#### Produces
677A list of atoms.
679#### Source
681```hoon
682 ++ rip
683 ~/ %rip
684 |= [a=bite b=@]
685 ^- (list @)
686 ?: =(0 b) ~
687 [(end a b) $(b (rsh a b))]
688```
690#### Examples
692```
693 > `@ub`155 :: @ub is the binary aura
694 0b1001.1011
696 > (rip 0 155)
697 ~[1 1 0 1 1 0 0 1]
699 > (rip 2 155)
700 ~[11 9]
702 > (rip 0 11)
703 ~[1 1 0 1]
705 > (rip 1 155)
706 ~[3 2 1 2]
708 > `@ub`256
709 0b1.0000.0000
711 > (rip 0 256)
712 ~[0 0 0 0 0 0 0 0 1]
714 > (rip 2 256)
715 ~[0 0 1]
717 > (rip 3 256)
718 ~[0 1]
720 > `tape`(rip 3 'abcd')
721 "abcd"
722```
724---
726### `++rsh`
728Right-shift
730Right-shifts `b` by `step` blocks of size `bloq`, producing an atom.
732#### Accepts
734`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
735which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
736with optional block count.
738`b` is an atom.
740#### Produces
742An atom.
744#### Source
746```hoon
747 ++ rsh
748 ~/ %rsh
749 |= [a=bite b=@]
750 =/ [=bloq =step] ?^(a a [a *step])
751 (div b (bex (mul (bex bloq) step)))
752```
754#### Examples
756```
757 > `@ub`145 :: @ub is the binary aura
758 0b1001.0001
760 > `@ub`(rsh [1 1] 145)
761 0b10.0100
763 > (rsh [1 1] 145)
764 36
766 > (rsh 1 145)
767 36
769 > `@ub`(rsh [2 1] 145)
770 0b1001
772 > (rsh [2 1] 145)
773 9
775 > `@ub`10
776 0b1010
778 > `@ub`(rsh [0 1] 10)
779 0b101
781 > (rsh [0 1] 10)
782 5
784 > `@ux`'abc'
785 0x63.6261
787 > `@t`(rsh [3 1] 'abc')
788 'bc'
790 > `@ux`(rsh [3 1] 'abc')
791 0x6362
792```
794---
796### `++run`
798`++turn` into atom.
800Disassembles atom `b` into slices specified by `a`, applies `c` to each slice,
801and reassembles the results back into an atom.
803#### Accepts
805`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
806which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
807with optional block count.
809`b` is an atom.
811`c` is a gate that accepts an atom and produces an atom.
813#### Produces
815An atom.
817#### Source
819```hoon
820 ++ run
821 ~/ %run
822 |= [a=bite b=@ c=$-(@ @)]
823 (rep a (turn (rip a b) c))
824```
826#### Examples
828```
829 > `@ux`65.535 :: @ux is the hexadecimal aura
830 0xffff
832 > `@ux`(run 2 65.535 dec) :: dec is the decrement gate
833 0xeeee
834```
836---
838### `++rut`
840`++turn` into list.
842Disassembles atom `b` into slices specified by `a`, applies `c` to each slice,
843and assembles the results back into a.
845#### Accepts
847`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
848which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
849with optional block count.
851`b` is an atom.
853`c` is a gate that accepts an atom.
855#### Produces
857A list.
859#### Source
861```hoon
862 ++ rut
863 ~/ %rut
864 |* [a=bite b=@ c=$-(@ *)]
865 (turn (rip a b) c)
866```
868#### Examples
870```
871 > `@ux`65.535 :: @ux is the hexadecimal aura
872 0xffff
874 > `(list @ux)`(rut 2 65.535 dec) :: dec is the decrement gate
875 ~[0xe 0xe 0xe 0xe]
876```
878---
880### `++swp`
882Reverse block order
884Switches little-endian to big-endian and vice versa: produces an atom by
885reversing the block order of `b` using block size `a`.
887#### Accepts
889`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
891`b` is an atom.
893#### Produces
895An atom
897#### Source
899```hoon
900 ++ swp |=([a=bloq b=@] (rep a (flop (rip a b))))
901```
903#### Examples
905```
906 > `@ub`24 :: @ub is the binary aura
907 0b1.1000
909 > (swp 0 24)
910 3
912 > `@ub`3
913 0b11
915 > (swp 0 0)
916 0
918 > (swp 0 128)
919 1
920```
922---
924### `++xeb`
926Binary logarithm
928Computes the base-2 logarithm of `a`, producing an atom.
930#### Accepts
932`a` is an atom.
934#### Produces
936An atom.
938#### Source
940```hoon
941 ++ xeb
942 ~/ %xeb
943 |= a=@
944 ^- @
945 (met 0 a)
946```
948#### Examples
950```
951 > (xeb 31)
952 5
954 > (xeb 32)
955 6
957 > (xeb 49)
958 6
960 > (xeb 0)
961 0
963 > (xeb 1)
964 1
966 > (xeb 2)
967 2
968```
970---
972### `++fe`
974Modulo bloq
976Core that contains arms for `bloq` and modular integer operations.
978#### Accepts
980`a` is a `bloq`.
982#### Source
984```hoon
985 |_ a=bloq
986```
988---
990### `++dif:fe`
992Produces the difference between two atoms in the modular basis
993representation.
995#### Accepts
997`a` is a `bloq`.
999`b` is an atom.
1001`c` is an atom.
1003#### Produces
1005A `@s`
1007#### Source
1009```hoon
1010 ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c))))
1011```
1013#### Examples
1015```
1016 > (~(dif fe 3) 63 64)
1017 255
1019 > (~(dif fe 3) 5 10)
1020 251
1022 > (~(dif fe 3) 0 1)
1023 255
1025 > (~(dif fe 0) 9 10)
1028 > (~(dif fe 0) 9 11)
1031 > (~(dif fe 0) 9 12)
1034 > (~(dif fe 2) 9 12)
1035 13
1037 > (~(dif fe 2) 63 64)
1038 15
1039```
1041---
1043### `++inv:fe`
1045Inverse
1047Inverts the order of the modular field.
1049#### Accepts
1051`b` is a `bloq`. (see [`++bloq`](/docs/hoon/reference/stdlib/1c))
1053#### Produces
1055An atom.
1057#### Source
1059```hoon
1060 ++ inv |=(b=@ (sub (dec out) (sit b)))
1061```
1063#### Examples
1065```
1066 > (~(inv fe 3) 255)
1069 > (~(inv fe 3) 256)
1070 255
1072 > (~(inv fe 3) 0)
1073 255
1075 > (~(inv fe 3) 1)
1076 254
1078 > (~(inv fe 3) 2)
1079 253
1081 > (~(inv fe 3) 55)
1082 200
1083```
1085---
1087### `++net:fe`
1089Flip endianness
1091Reverses bytes within a block.
1093#### Accepts
1095`b` is a `bloq`. (see [`++bloq`](/docs/hoon/reference/stdlib/1c))
1097#### Produces
1099An atom.
1101#### Source
1103```hoon
1104 ++ net |= b=@ ^- @
1105 => .(b (sit b))
1106 ?: (lte a 3)
1108 =+ c=(dec a)
1109 %+ con
1110 (lsh c 1 $(a c, b (cut c [0 1] b)))
1111 $(a c, b (cut c [1 1] b))
1112```
1114#### Examples
1116```
1117 > (~(net fe 3) 64)
1118 64
1120 > (~(net fe 3) 128)
1121 128
1123 > (~(net fe 3) 255)
1124 255
1126 > (~(net fe 3) 256)
1129 > (~(net fe 3) 257)
1132 > (~(net fe 3) 500)
1133 244
1135 > (~(net fe 3) 511)
1136 255
1138 > (~(net fe 3) 512)
1141 > (~(net fe 3) 513)
1144 > (~(net fe 3) 0)
1147 > (~(net fe 3) 1)
1150 > (~(net fe 0) 1)
1153 > (~(net fe 0) 2)
1156 > (~(net fe 0) 3)
1159 > (~(net fe 6) 1)
1160 72.057.594.037.927.936
1162 > (~(net fe 6) 2)
1163 144.115.188.075.855.872
1165 > (~(net fe 6) 3)
1166 216.172.782.113.783.808
1168 > (~(net fe 6) 4)
1169 288.230.376.151.711.744
1171 > (~(net fe 6) 5)
1172 360.287.970.189.639.680
1173```
1175---
1177### `++out:fe`
1179Max integer value
1181Produces the maximum integer value that the current block can store; `2^a^a`.
1183#### Accepts
1185`a` is a `bloq`.
1187#### Produces
1189An atom.
1191#### Source
1193```hoon
1194 ++ out (bex (bex a))
1195```
1197#### Examples
1199```
1200 > ~(out fe 0)
1203 > ~(out fe 1)
1206 > ~(out fe 2)
1207 16
1209 > ~(out fe 3)
1210 256
1212 > ~(out fe 4)
1213 65.536
1215 > ~(out fe 10)
1216 \/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.273\/
1217 .430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113.879.87
1218 1.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767.893.424.8
1219 65.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838.150.682.342.
1220 462.881.473.913.110.540.827.237.163.350.510.684.586.298.239.947.245.938.479
1221 .716.304.835.356.329.624.224.137.216
1222 \/ \/
1223```
1225---
1227### `++rol:fe`
1229Roll left
1231Rolls `d` to the left by `c` `b`-sized blocks.
1233#### Accepts
1235`a` is a `bloq`.
1237`b` is a `bloq`.
1239`c` is an atom.
1241`d` is an atom.
1243#### Produces
1245An atom.
1247#### Source
1249```hoon
1250 ++ rol |= [b=bloq c=@ d=@] ^- @
1251 =+ e=(sit d)
1252 =+ f=(bex (sub a b))
1253 =+ g=(mod c f)
1254 (sit (con (lsh b g e) (rsh b (sub f g) e)))
1255```
1257#### Examples
1259```
1260 > `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213)
1261 0x1213.0000.abac.dedf
1263 > `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213)
1264 0xdedf.1213.0000.abac
1266 > `@t`(~(rol fe 5) 3 1 'dfgh')
1267 'hdfg'
1269 > `@t`(~(rol fe 5) 3 2 'dfgh')
1270 'ghdf'
1272 > `@t`(~(rol fe 5) 3 0 'dfgh')
1273 'dfgh'
1274```
1276---
1278### `++ror:fe`
1280Roll right
1282Rolls `d` to the right by `c` `b`-sized blocks.
1284#### Accepts
1286`a` is a `bloq`.
1288`b` is a `bloq`.
1290`c` is an atom.
1292`d` is an atom.
1294#### Produces
1296An atom.
1298#### Source
1300```hoon
1301 ++ ror |= [b=bloq c=@ d=@] ^- @
1302 =+ e=(sit d)
1303 =+ f=(bex (sub a b))
1304 =+ g=(mod c f)
1305 (sit (con (rsh b g e) (lsh b (sub f g) e)))
1306```
1308#### Examples
1310```
1311 > `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213)
1312 0x1213.0000.abac.dedf
1314 > `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213)
1315 0xacde.df12.1300.00ab
1317 > `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213)
1318 0xdf12.1300.00ab.acde
1320 > `@t`(~(rol fe 5) 3 0 'hijk')
1321 'hijk'
1323 > `@t`(~(rol fe 5) 3 1 'hijk')
1324 'khij'
1326 > `@t`(~(rol fe 5) 3 2 'hijk')
1327 'jkhi'
1328```
1330---
1332### `++sit:fe`
1334Enforce modulo
1336Produces an atom in the current modular block representation.
1338#### Accepts
1340`a` is a `bloq`.
1342`b` is an atom.
1344#### Produces
1346An atom.
1348#### Source
1350```hoon
1351 ++ sit |=(b=@ (end a 1 b))
1352```
1354#### Examples
1356```
1357 > (~(sit fe 3) 255)
1358 255
1360 > (~(sit fe 3) 256)
1363 > (~(sit fe 3) 257)
1366 > (~(sit fe 2) 257)
1369 > (~(sit fe 2) 10.000)
1372 > (~(sit fe 2) 100)
1375 > (~(sit fe 2) 19)
1378 > (~(sit fe 2) 17)
1381 > (~(sit fe 0) 17)
1384 > (~(sit fe 0) 0)
1387 > (~(sit fe 0) 1)
1389```
1391---
1393### `++sum:fe`
1395Sum
1397Sums two numbers in this modular field.
1399#### Accepts
1401`a` is a `bloq`.
1403`b` is an atom.
1405`c` is an atom.
1407#### Produces
1409An atom.
1411#### Source
1413```hoon
1414 ++ sum |=([b=@ c=@] (sit (add b c)))
1415```
1417#### Examples
1419```
1420 > (~(sum fe 3) 10 250)
1423 > (~(sum fe 0) 0 1)
1426 > (~(sum fe 0) 0 2)
1429 > (~(sum fe 2) 14 2)
1432 > (~(sum fe 2) 14 3)
1435 > (~(sum fe 4) 10.000 256)
1436 10.256
1438 > (~(sum fe 4) 10.000 100.000)
1439 44.464
1440```
1442---