Skip to content

Commit a29e0f9

Browse files
authored
doc (#490)
1 parent 8f0660f commit a29e0f9

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

contract/p/gnoswap/uint256/bits_table.gno

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
// Copyright 2017 The Go Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
4-
5-
// Code generated by go run make_tables.go. DO NOT EDIT.
6-
74
package uint256
85

6+
// ntz8tab: A lookup table for 8-bit values (0-255) that shows
7+
// the number of trailing zeros (zeros from the rightmost/LSB position).
8+
//
9+
// Example) 0x28 (binary 00101000)
10+
//
11+
// Binary: [ 0 0 1 0 1 0 0 0 ]
12+
// ^^^^^^^^
13+
// 3 consecutive zeros
14+
//
15+
// ntz8tab[0x28] = 3
916
const ntz8tab = "" +
1017
"\x08\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +
1118
"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +
@@ -24,6 +31,15 @@ const ntz8tab = "" +
2431
"\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +
2532
"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00"
2633

34+
// pop8tab: A lookup table for 8-bit values (0-255) that allows
35+
// quick lookup of the number of set bits (bits set to 1).
36+
//
37+
// Example) 0xB2 (binary 10110010)
38+
//
39+
// Binary: [ 1 0 1 1 0 0 1 0 ]
40+
// Total of 4 set bits
41+
//
42+
// pop8tab[0xB2] = 4
2743
const pop8tab = "" +
2844
"\x00\x01\x01\x02\x01\x02\x02\x03\x01\x02\x02\x03\x02\x03\x03\x04" +
2945
"\x01\x02\x02\x03\x02\x03\x03\x04\x02\x03\x03\x04\x03\x04\x04\x05" +
@@ -42,6 +58,15 @@ const pop8tab = "" +
4258
"\x03\x04\x04\x05\x04\x05\x05\x06\x04\x05\x05\x06\x05\x06\x06\x07" +
4359
"\x04\x05\x05\x06\x05\x06\x06\x07\x05\x06\x06\x07\x06\x07\x07\x08"
4460

61+
// rev8tab: A lookup table that pre-calculates bit-reversed results
62+
// for 8-bit values (0-255).
63+
//
64+
// Example) 0x16 (binary 00010110)
65+
//
66+
// Binary: [ 0 0 0 1 0 1 1 0 ]
67+
// Reversed: [ 0 1 1 0 1 0 0 0 ] -> 0x68 (104 in decimal)
68+
//
69+
// rev8tab[0x16] = 0x68
4570
const rev8tab = "" +
4671
"\x00\x80\x40\xc0\x20\xa0\x60\xe0\x10\x90\x50\xd0\x30\xb0\x70\xf0" +
4772
"\x08\x88\x48\xc8\x28\xa8\x68\xe8\x18\x98\x58\xd8\x38\xb8\x78\xf8" +
@@ -60,6 +85,17 @@ const rev8tab = "" +
6085
"\x07\x87\x47\xc7\x27\xa7\x67\xe7\x17\x97\x57\xd7\x37\xb7\x77\xf7" +
6186
"\x0f\x8f\x4f\xcf\x2f\xaf\x6f\xef\x1f\x9f\x5f\xdf\x3f\xbf\x7f\xff"
6287

88+
// len8tab: A lookup table that pre-calculates the "bit length"
89+
// of 8-bit values (0-255).
90+
// (Bit length: position of the most significant bit + 1)
91+
//
92+
// Examples)
93+
//
94+
// 0x00 (binary 00000000) → No MSB → length 0
95+
// 0x01 (binary 00000001) → MSB at rightmost position → length 1
96+
// 0x02 (binary 00000010) ~ 0x03 (00000011) → length 2
97+
// 0x04 (binary 00000100) ~ 0x07 (00000111) → length 3
98+
// ...
6399
const len8tab = "" +
64100
"\x00\x01\x02\x02\x03\x03\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04" +
65101
"\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05" +

0 commit comments

Comments
 (0)