on cb112e8 help sign in
1364 lines 19 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---
46### `++can`
48Assemble
50Produces an atom from a list `b` of length-value pairs `p` and `q`,
51where `p` is the length in blocks of size `a`, and `q` is an atomic
52value.
54#### Accepts
56`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
58`b` is a `list` of length-value pairs, `p` and `q`.
60#### Produces
62An atom.
64#### Source
66```hoon
67 ++ can
68 ~/ %can
69 |= [a=bloq b=(list [p=@ q=@])]
70 ^- @
71 ?~ b 0
72 (add (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b)))
73```
75#### Examples
77```
78 > `@ub`21 :: @ub is the binary aura
79 0b1.0101
81 > `@ub`(can 3 ~[[1 21]])
82 0b1.0101
84 > `@ub`(can 3 ~[[1 1]])
85 0b1
87 > `@ub`(can 0 ~[[1 255]])
88 0b1
90 > `@ux`(can 3 [3 0xc1] [1 0xa] ~) :: @ux is the hexadecimal aura
91 0xa00.00c1
93 > `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~)
94 0x23.0a00.00c1
96 > `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~)
97 0x23.000a.0000.0000.00c1
99 > `@ux`(can 3 ~[[1 'a'] [2 'bc']])
100 0x63.6261
101```
103---
104### `++cat`
106Concatenate
108Concatenates two atoms, `b` and `c`, according to block size `a`, producing an
109atom.
111#### Accepts
113`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
115`b` is an atom.
117`c` is an atom.
119#### Produces
121An atom.
123#### Source
125```hoon
126 ++ cat
127 ~/ %cat
128 |= [a=bloq b=@ c=@]
129 (add (lsh a (met a b) c) b)
130```
132#### Examples
134```
135 > `@ub`(cat 3 1 0) :: @ub is the binary aura
136 0b1
138 > `@ub`(cat 0 1 1)
139 0b11
141 > `@ub`(cat 0 2 1)
142 0b110
144 > `@ub`(cat 2 1 1)
145 0b1.0001
147 > `@ub`256
148 0b1.0000.0000
150 > `@ub`255
151 0b1111.1111
153 > `@ub`(cat 3 256 255)
154 0b1111.1111.0000.0001.0000.0000
156 > `@ub`(cat 2 256 255)
157 0b1111.1111.0001.0000.0000
159 > (cat 3 256 255)
160 16.711.936
162 > (cat 2 256 255)
163 1.044.736
164```
166---
167### `++cut`
169Slice
171Slices `c` blocks of size `a` that are positioned `b` blocks from the end of
172`d`. That slice is produced as an atom.
174#### Accepts
176`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
178`b` is an atom.
180`c` is an atom.
182`d` is an atom.
184#### Produces
186An atom.
188#### Source
190```hoon
191 ++ cut
192 ~/ %cut
193 |= [a=bloq [b=@u c=@u] d=@]
194 (end a c (rsh a b d))
195```
197#### Examples
199```
200 > (cut 0 [1 1] 2)
201 1
203 > (cut 0 [2 1] 4)
204 1
206 > `@t`(cut 3 [0 3] 'abcdefgh')
207 'abc'
209 > `@t`(cut 3 [1 3] 'abcdefgh') :: @t is the cord aura
210 'bcd'
212 > `@ub`(cut 0 [0 3] 0b1111.0000.1101) :: @ub is the binary aura
213 0b101
215 > `@ub`(cut 0 [0 6] 0b1111.0000.1101)
216 0b1101
218 > `@ub`(cut 0 [4 6] 0b1111.0000.1101)
219 0b11.0000
221 > `@ub`(cut 0 [3 6] 0b1111.0000.1101)
222 0b10.0001
223```
226---
227### `++end`
229Tail
231Produces an atom by taking the last `step` blocks of size `bloq` from `b`.
233#### Accepts
235`a` is an atom slice specifier (see [`++bite`](/docs/hoon/reference/stdlib/1c#bite)),
236which is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c#bloq))
237with optional block count.
239`b` is an atom.
241#### Produces
243An atom.
246#### Source
248```hoon
249 ++ end
250 ~/ %end
251 |= [a=bite b=@]
252 =/ [=bloq =step] ?^(a a [a *step])
253 (mod b (bex (mul (bex bloq) step)))
254```
256#### Examples
258```
259 > (end [2 2] 255)
260 255
262 > (end [3 1] 255)
263 255
265 > (end 3 255)
266 255
268 > (end 3 256)
269 0
271 > `@ub`12 :: @ub is the binary aura
272 0b1100
274 > `@ub`(end [0 3] 12)
275 0b100
277 > (end [0 3] 12)
278 4
280 > `@ub`(end [1 3] 12)
281 0b1100
283 > (end [1 3] 12)
284 12
286 > `@ux`'abc' :: @ux is the hexademical aura
287 0x63.6261
289 > `@ux`(end [3 2] 'abc')
290 0x6261
292 > `@t`(end [3 2] 'abc') :: @t is the cord aura
293 'ab'
294```
297---
298### `++fil`
300Fill bloqstream
302Produces an atom by repeating `c` for `b` blocks of size `a`.
304#### Accepts
306`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
308`b` is an atom.
310`c` is an atom.
312#### Produces
314An atom.
316#### Source
318```hoon
319 ++ fil
320 |= [a=bloq b=@u c=@]
321 =+ n=0
322 =+ d=c
323 |- ^- @
324 ?: =(n b)
325 (rsh a 1 d)
326 $(d (add c (lsh a 1 d)), n +(n))
327```
329#### Examples
331```
332 > `@t`(fil 3 5 %a) :: @t is the cord (string) aura
333 'aaaaa'
335 > `@t`(fil 5 10 %ceeb)
336 'ceebceebceebceebceebceebceebceebceebceeb'
338 > `@t`(fil 4 10 %eced)
339 'ʇʇʇʇʇʇʇʇʇʇed'
341 > `@tas`(fil 4 10 %bf) :: @tas is the term aura
342 %bfbfbfbfbfbfbfbfbfbf
344 > `@ub`(fil 2 6 1) :: @ub is the binary aura
345 0b1.0001.0001.0001.0001.0001
346```
349---
350### `++lsh`
352Left-shift
354Produces an atom by left-shifting `b` by `step` blocks of size `bloq`.
356#### Accepts
358`a` is an atom slice specifier (see [`++bite`](/docs/hoon/reference/stdlib/1c#bite)),
359which is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c#bloq))
360with optional block count.
362`b` is an atom.
364#### Produces
366An atom.
368#### Source
370```hoon
371 ++ lsh
372 ~/ %lsh
373 |= [a=bite b=@]
374 =/ [=bloq =step] ?^(a a [a *step])
375 (mul b (bex (mul (bex bloq) step)))
376```
378#### Examples
380```
381 > `@ub`1 :: @ub is the binary aura
382 0b1
384 > `@ub`(lsh [0 1] 1)
385 0b10
387 > (lsh [0 1] 1)
388 2
390 > (lsh 0 1)
391 2
393 > `@ub`255
394 0b1111.1111
396 > `@ub`(lsh [3 1] 255)
397 0b1111.1111.0000.0000
399 > (lsh [3 1] 255)
400 65.280
401```
404---
405### `++met`
407Measure
409Computes the number of blocks of size `a` in `b`, producing an atom.
411#### Accepts
413`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
415`b` is an atom.
417#### Source
419```hoon
420 ++ met
421 ~/ %met
422 |= [a=bloq b=@]
423 ^- @
424 =+ c=0
425 |-
426 ?: =(0 b) c
427 $(b (rsh a 1 b), c +(c))
428```
430#### Examples
432```
433 > (met 0 1)
434 1
436 > (met 0 2)
437 2
439 > (met 3 255)
440 1
442 > (met 3 256)
443 2
445 > (met 3 'abcde')
446 5
447```
450---
451### `++rap`
453Assemble non-zero
455Concatenates a list of atoms `b` using block size `a`, producing an atom.
457#### Accepts
459`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
461`b` is a `list` of atoms.
463#### Produces
465An atom.
467#### Source
469```hoon
470 ++ rap
471 ~/ %rap
472 |= [a=bloq b=(list @)]
473 ^- @
474 =+ ~
475 ?~ b 0
476 (cat a i.b $(b t.b))
477```
479#### Examples
481```
482 > `@ub`(rap 2 [1 2 3 4 ~]) :: @ub is the binary aura
483 0b100.0011.0010.0001
485 > `@ub`(rap 1 [1 2 3 4 ~])
486 0b1.0011.1001
488 > (rap 0 [0 0 0 ~])
489 0
491 > (rap 0 [1 0 1 ~])
492 3
494 > `@ub`3
495 0b11
497 > (rap 0 [0 1 0 0 1 2 ~])
498 11
500 > (rap 0 [1 1 2 ~])
501 11
503 > `@ub`11
504 0b1011
505```
507#### Discussion
509Any element of the value `0` is not included in concatenation.
511---
512### `++rep`
514Assemble single
516Produces an atom by assembling a list of atoms `b` using block size `a`.
518#### Accepts
520`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
521which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
522with optional block count.
524`b` is a list of atoms.
526#### Produces
528An atom.
530#### Source
532```hoon
533 ++ rep
534 ~/ %rep
535 |= [a=bite b=(list @)]
536 =/ [=bloq =step] ?^(a a [a *step])
537 =| i=@ud
538 |- ^- @
539 ?~ b 0
540 %+ add $(i +(i), b t.b)
541 (lsh [bloq (mul step i)] (end [bloq step] i.b))
542```
544#### Examples
546```
547 > `@ub`(rep 2 [1 2 3 4 ~]) :: @ub is the binary aura
548 0b100.0011.0010.0001
550 > (rep 0 [0 0 1 ~])
551 4
553 > (rep 0 [0 0 0 1 ~])
554 8
556 > `@ub`(rep 0 [0 0 0 1 ~])
557 0b1000
559 > `@ub`8
560 0b1000
562 > `@ub`(rep 0 [1 0 1 0 ~])
563 0b101
565 > `@ub`(rep 0 [1 2 3 4 ~])
566 0b101
568 > (rep 0 [0 1 0 1 ~])
569 10
571 > (rep 0 [1 0 1 0 1 ~])
572 21
574 > `@ub`21
575 0b10.1010
577 > `@ub`(rep 3 [12 166 8 34 ~])
578 0b10.0010.0000.1000.1010.0110.0000.1100
580 > `*`"abcd"
581 [97 98 99 100 0]
583 > `@t`(rep 3 "abcd") :: @t is the text aura
584 'abcd'
585```
588---
589### `++rip`
591Disassemble
593Produces a list of atoms from the bits of `b` using block size `a`.
595#### Accepts
597`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
598which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
599with optional block count.
601`b` is an atom.
603#### Produces
605A list of atoms.
607#### Source
609```hoon
610 ++ rip
611 ~/ %rip
612 |= [a=bite b=@]
613 ^- (list @)
614 ?: =(0 b) ~
615 [(end a b) $(b (rsh a b))]
616```
618#### Examples
620```
621 > `@ub`155 :: @ub is the binary aura
622 0b1001.1011
624 > (rip 0 155)
625 ~[1 1 0 1 1 0 0 1]
627 > (rip 2 155)
628 ~[11 9]
630 > (rip 0 11)
631 ~[1 1 0 1]
633 > (rip 1 155)
634 ~[3 2 1 2]
636 > `@ub`256
637 0b1.0000.0000
639 > (rip 0 256)
640 ~[0 0 0 0 0 0 0 0 1]
642 > (rip 2 256)
643 ~[0 0 1]
645 > (rip 3 256)
646 ~[0 1]
648 > `tape`(rip 3 'abcd')
649 "abcd"
650```
653---
654### `++rsh`
656Right-shift
658Right-shifts `b` by `step` blocks of size `bloq`, producing an atom.
660#### Accepts
662`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
663which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
664with optional block count.
666`b` is an atom.
668#### Produces
670An atom.
672#### Source
674```hoon
675 ++ rsh
676 ~/ %rsh
677 |= [a=bite b=@]
678 =/ [=bloq =step] ?^(a a [a *step])
679 (div b (bex (mul (bex bloq) step)))
680```
682#### Examples
684```
685 > `@ub`145 :: @ub is the binary aura
686 0b1001.0001
688 > `@ub`(rsh [1 1] 145)
689 0b10.0100
691 > (rsh [1 1] 145)
692 36
694 > (rsh 1 145)
695 36
697 > `@ub`(rsh [2 1] 145)
698 0b1001
700 > (rsh [2 1] 145)
701 9
703 > `@ub`10
704 0b1010
706 > `@ub`(rsh [0 1] 10)
707 0b101
709 > (rsh [0 1] 10)
710 5
712 > `@ux`'abc'
713 0x63.6261
715 > `@t`(rsh [3 1] 'abc')
716 'bc'
718 > `@ux`(rsh [3 1] 'abc')
719 0x6362
720```
723---
724### `++run`
726`++turn` into atom.
728Disassembles atom `b` into slices specified by `a`, applies `c` to each slice,
729and reassembles the results back into an atom.
731#### Accepts
733`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
734which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
735with optional block count.
737`b` is an atom.
739`c` is a gate that accepts an atom and produces an atom.
741#### Produces
743An atom.
745#### Source
747```hoon
748 ++ run
749 ~/ %run
750 |= [a=bite b=@ c=$-(@ @)]
751 (rep a (turn (rip a b) c))
752```
754#### Examples
756```
757 > `@ux`65.535 :: @ux is the hexadecimal aura
758 0xffff
760 > `@ux`(run 2 65.535 dec) :: dec is the decrement gate
761 0xeeee
762```
765---
766### `++rut`
768`++turn` into list.
770Disassembles atom `b` into slices specified by `a`, applies `c` to each slice,
771and assembles the results back into a.
773#### Accepts
775`a` is an atom slice specifier (see [`$bite`](/docs/hoon/reference/stdlib/1c#bite)),
776which is a block size (see [`$bloq`](/docs/hoon/reference/stdlib/1c#bloq))
777with optional block count.
779`b` is an atom.
781`c` is a gate that accepts an atom.
783#### Produces
785A list.
787#### Source
789```hoon
790 ++ rut
791 ~/ %rut
792 |* [a=bite b=@ c=$-(@ *)]
793 (turn (rip a b) c)
794```
796#### Examples
798```
799 > `@ux`65.535 :: @ux is the hexadecimal aura
800 0xffff
802 > `(list @ux)`(rut 2 65.535 dec) :: dec is the decrement gate
803 ~[0xe 0xe 0xe 0xe]
804```
807---
808### `++swp`
810Reverse block order
812Switches little-endian to big-endian and vice versa: produces an atom by
813reversing the block order of `b` using block size `a`.
816#### Accepts
818`a` is a block size (see [`++bloq`](/docs/hoon/reference/stdlib/1c)).
820`b` is an atom.
822#### Produces
824An atom
826#### Source
828```hoon
829 ++ swp |=([a=bloq b=@] (rep a (flop (rip a b))))
830```
832#### Examples
834```
835 > `@ub`24 :: @ub is the binary aura
836 0b1.1000
838 > (swp 0 24)
839 3
841 > `@ub`3
842 0b11
844 > (swp 0 0)
845 0
847 > (swp 0 128)
848 1
849```
852---
853### `++xeb`
855Binary logarithm
857Computes the base-2 logarithm of `a`, producing an atom.
859#### Accepts
861`a` is an atom.
863#### Produces
865An atom.
867#### Source
869```hoon
870 ++ xeb
871 ~/ %xeb
872 |= a=@
873 ^- @
874 (met 0 a)
875```
877#### Examples
879```
880 > (xeb 31)
881 5
883 > (xeb 32)
884 6
886 > (xeb 49)
887 6
889 > (xeb 0)
890 0
892 > (xeb 1)
893 1
895 > (xeb 2)
896 2
897```
900---
901### `++fe`
903Modulo bloq
905Core that contains arms for `bloq` and modular integer operations.
907#### Accepts
909`a` is a `bloq`.
911#### Source
913```hoon
914 |_ a=bloq
915```
917---
918### `++dif:fe`
920Produces the difference between two atoms in the modular basis
921representation.
923#### Accepts
925`a` is a `bloq`.
927`b` is an atom.
929`c` is an atom.
931#### Produces
933A `@s`
935#### Source
937```hoon
938 ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c))))
939```
941#### Examples
943```
944 > (~(dif fe 3) 63 64)
945 255
947 > (~(dif fe 3) 5 10)
948 251
950 > (~(dif fe 3) 0 1)
951 255
953 > (~(dif fe 0) 9 10)
954 1
956 > (~(dif fe 0) 9 11)
957 0
959 > (~(dif fe 0) 9 12)
960 1
962 > (~(dif fe 2) 9 12)
963 13
965 > (~(dif fe 2) 63 64)
966 15
967```
969---
970### `++inv:fe`
972Inverse
974Inverts the order of the modular field.
976#### Accepts
978`b` is a `bloq`. (see [`++bloq`](/docs/hoon/reference/stdlib/1c))
980#### Produces
982An atom.
984#### Source
986```hoon
987 ++ inv |=(b=@ (sub (dec out) (sit b)))
988```
990#### Examples
992```
993 > (~(inv fe 3) 255)
994 0
996 > (~(inv fe 3) 256)
997 255
999 > (~(inv fe 3) 0)
1000 255
1002 > (~(inv fe 3) 1)
1003 254
1005 > (~(inv fe 3) 2)
1006 253
1008 > (~(inv fe 3) 55)
1009 200
1010```
1012---
1013### `++net:fe`
1015Flip endianness
1017Reverses bytes within a block.
1019#### Accepts
1021`b` is a `bloq`. (see [`++bloq`](/docs/hoon/reference/stdlib/1c))
1023#### Produces
1025An atom.
1027#### Source
1029```hoon
1030 ++ net |= b=@ ^- @
1031 => .(b (sit b))
1032 ?: (lte a 3)
1034 =+ c=(dec a)
1035 %+ con
1036 (lsh c 1 $(a c, b (cut c [0 1] b)))
1037 $(a c, b (cut c [1 1] b))
1038```
1040#### Examples
1042```
1043 > (~(net fe 3) 64)
1044 64
1046 > (~(net fe 3) 128)
1047 128
1049 > (~(net fe 3) 255)
1050 255
1052 > (~(net fe 3) 256)
1055 > (~(net fe 3) 257)
1058 > (~(net fe 3) 500)
1059 244
1061 > (~(net fe 3) 511)
1062 255
1064 > (~(net fe 3) 512)
1067 > (~(net fe 3) 513)
1070 > (~(net fe 3) 0)
1073 > (~(net fe 3) 1)
1076 > (~(net fe 0) 1)
1079 > (~(net fe 0) 2)
1082 > (~(net fe 0) 3)
1085 > (~(net fe 6) 1)
1086 72.057.594.037.927.936
1088 > (~(net fe 6) 2)
1089 144.115.188.075.855.872
1091 > (~(net fe 6) 3)
1092 216.172.782.113.783.808
1094 > (~(net fe 6) 4)
1095 288.230.376.151.711.744
1097 > (~(net fe 6) 5)
1098 360.287.970.189.639.680
1099```
1101---
1102### `++out:fe`
1104Max integer value
1106Produces the maximum integer value that the current block can store; `2^a^a`.
1108#### Accepts
1110`a` is a `bloq`.
1112#### Produces
1114An atom.
1116#### Source
1118```hoon
1119 ++ out (bex (bex a))
1120```
1122#### Examples
1124```
1125 > ~(out fe 0)
1128 > ~(out fe 1)
1131 > ~(out fe 2)
1132 16
1134 > ~(out fe 3)
1135 256
1137 > ~(out fe 4)
1138 65.536
1140 > ~(out fe 10)
1141 \/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.273\/
1142 .430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113.879.87
1143 1.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767.893.424.8
1144 65.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838.150.682.342.
1145 462.881.473.913.110.540.827.237.163.350.510.684.586.298.239.947.245.938.479
1146 .716.304.835.356.329.624.224.137.216
1147 \/ \/
1148```
1150---
1151### `++rol:fe`
1153Roll left
1155Rolls `d` to the left by `c` `b`-sized blocks.
1157#### Accepts
1159`a` is a `bloq`.
1161`b` is a `bloq`.
1163`c` is an atom.
1165`d` is an atom.
1167#### Produces
1169An atom.
1171#### Source
1173```hoon
1174 ++ rol |= [b=bloq c=@ d=@] ^- @
1175 =+ e=(sit d)
1176 =+ f=(bex (sub a b))
1177 =+ g=(mod c f)
1178 (sit (con (lsh b g e) (rsh b (sub f g) e)))
1179```
1181#### Examples
1183```
1184 > `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213)
1185 0x1213.0000.abac.dedf
1187 > `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213)
1188 0xdedf.1213.0000.abac
1190 > `@t`(~(rol fe 5) 3 1 'dfgh')
1191 'hdfg'
1193 > `@t`(~(rol fe 5) 3 2 'dfgh')
1194 'ghdf'
1196 > `@t`(~(rol fe 5) 3 0 'dfgh')
1197 'dfgh'
1198```
1200---
1201### `++ror:fe`
1203Roll right
1205Rolls `d` to the right by `c` `b`-sized blocks.
1207#### Accepts
1209`a` is a `bloq`.
1211`b` is a `bloq`.
1213`c` is an atom.
1215`d` is an atom.
1217#### Produces
1219An atom.
1221#### Source
1223```hoon
1224 ++ ror |= [b=bloq c=@ d=@] ^- @
1225 =+ e=(sit d)
1226 =+ f=(bex (sub a b))
1227 =+ g=(mod c f)
1228 (sit (con (rsh b g e) (lsh b (sub f g) e)))
1229```
1231#### Examples
1233```
1234 > `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213)
1235 0x1213.0000.abac.dedf
1237 > `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213)
1238 0xacde.df12.1300.00ab
1240 > `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213)
1241 0xdf12.1300.00ab.acde
1243 > `@t`(~(rol fe 5) 3 0 'hijk')
1244 'hijk'
1246 > `@t`(~(rol fe 5) 3 1 'hijk')
1247 'khij'
1249 > `@t`(~(rol fe 5) 3 2 'hijk')
1250 'jkhi'
1251```
1253---
1254### `++sit:fe`
1256Enforce modulo
1258Produces an atom in the current modular block representation.
1260#### Accepts
1262`a` is a `bloq`.
1264`b` is an atom.
1266#### Produces
1268An atom.
1270#### Source
1272```hoon
1273 ++ sit |=(b=@ (end a 1 b))
1274```
1276#### Examples
1278```
1279 > (~(sit fe 3) 255)
1280 255
1282 > (~(sit fe 3) 256)
1285 > (~(sit fe 3) 257)
1288 > (~(sit fe 2) 257)
1291 > (~(sit fe 2) 10.000)
1294 > (~(sit fe 2) 100)
1297 > (~(sit fe 2) 19)
1300 > (~(sit fe 2) 17)
1303 > (~(sit fe 0) 17)
1306 > (~(sit fe 0) 0)
1309 > (~(sit fe 0) 1)
1311```
1313---
1315### `++sum:fe`
1317Sum
1319Sums two numbers in this modular field.
1321#### Accepts
1323`a` is a `bloq`.
1325`b` is an atom.
1327`c` is an atom.
1329#### Produces
1331An atom.
1333#### Source
1335```hoon
1336 ++ sum |=([b=@ c=@] (sit (add b c)))
1337```
1339#### Examples
1341```
1342 > (~(sum fe 3) 10 250)
1345 > (~(sum fe 0) 0 1)
1348 > (~(sum fe 0) 0 2)
1351 > (~(sum fe 2) 14 2)
1354 > (~(sum fe 2) 14 3)
1357 > (~(sum fe 4) 10.000 256)
1358 10.256
1360 > (~(sum fe 4) 10.000 100.000)
1361 44.464
1362```
1364---