Skip to content

Commit 3f9d9e4

Browse files
committed
.
1 parent 7dcb570 commit 3f9d9e4

25 files changed

+2358
-721
lines changed

docs/packages/Bits.md

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,37 @@
66

77
**Contract type:** Static library
88

9-
The `Bits` library is used for working with the individual bits of a `uint`.
9+
**Source file:** [Bits.sol](../../src/bits/Bits.sol)
10+
11+
**Example usage:** [BitsExamples.sol](../../examples/bits/BitsExamples.sol)
12+
13+
**Tests source file:** [bits_tests.sol](../../test/bits/bits_tests.sol)
14+
15+
**Perf (gas usage) source file:** [bits_perfs.sol](../../perf/bits/bits_perfs.sol)
1016

11-
**Example usage:** [BitsExamples.sol](../../examples/bits/BitsExamples.sol)})
17+
18+
## description
19+
20+
The `Bits` library is used for working with the individual bits of a `uint`.
1221

1322
## Functions
1423

15-
- [setBit(uint, uint8)](#setBit)
16-
- [clearBit(uint, uint8)](#clearBit)
17-
- [toggleBit(uint, uint8)](#toggleBit)
18-
- [bit(uint, uint8)](#bit)
19-
- [bitSet(uint, uint8)](#bitSet)
20-
- [bitEqual(uint, uint, uint8)](#bitEqual)
21-
- [bitAnd(uint, uint, uint8)](#bitAnd)
22-
- [bitOr(uint, uint, uint8)](#bitOr)
23-
- [bitXor(uint, uint, uint8)](#bitXor)
24-
- [bits(uint, uint8, uint16)](#bits)
25-
- [highestBitSet(uint)](#highestBitSet)
26-
- [lowestBitSet(uint)](#lowestBitSet)
24+
- [setBit(uint, uint8)](#setbituint-uint8)
25+
- [clearBit(uint, uint8)](#clearbituint-uint8)
26+
- [toggleBit(uint, uint8)](#togglebituint-uint8)
27+
- [bit(uint, uint8)](#bituint-uint8)
28+
- [bitSet(uint, uint8)](#bitsetuint-uint8)
29+
- [bitEqual(uint, uint, uint8)](#bitequaluint-uint-uint8)
30+
- [bitAnd(uint, uint, uint8)](#bitanduint-uint-uint8)
31+
- [bitOr(uint, uint, uint8)](#bitoruint-uint-uint8)
32+
- [bitXor(uint, uint, uint8)](#bitxoruint-uint-uint8)
33+
- [bits(uint, uint8, uint16)](#bitsuint-uint8-uint16)
34+
- [highestBitSet(uint)](#highestbitsetuint)
35+
- [lowestBitSet(uint)](#lowestbitsetuint)
2736

2837
***
2938

30-
### <a name="setBit"/>setBit(uint, uint8)
39+
### setBit(uint, uint8)
3140

3241
`function setBit(uint, uint8) internal pure returns (uint)`
3342

@@ -48,11 +57,11 @@ Sets the bit at position `index` to `1`.
4857
- `self.setBit(index) >> index & 1 == 1`
4958
##### gascosts
5059

51-
- Fixed: 161
60+
- Fixed: **161**
5261

5362
***
5463

55-
### <a name="clearBit"/>clearBit(uint, uint8)
64+
### clearBit(uint, uint8)
5665

5766
`function clearBit(uint, uint8) internal pure returns (uint)`
5867

@@ -73,11 +82,11 @@ Sets the bit at position `index` to `0`.
7382
- `self.setBit(index) >> index & 1 == 0`
7483
##### gascosts
7584

76-
- Fixed: 164
85+
- Fixed: **164**
7786

7887
***
7988

80-
### <a name="toggleBit"/>toggleBit(uint, uint8)
89+
### toggleBit(uint, uint8)
8190

8291
`function toggleBit(uint, uint8) internal pure returns (uint)`
8392

@@ -98,11 +107,11 @@ Toggles the bit at position `index`.
98107
- `newField = self.toggleBit(index) => newField.bit(index) == 1 - self.bit(index)`
99108
##### gascosts
100109

101-
- Fixed: 161
110+
- Fixed: **161**
102111

103112
***
104113

105-
### <a name="bit"/>bit(uint, uint8)
114+
### bit(uint, uint8)
106115

107116
`function bit(uint, uint8) internal pure returns (uint8)`
108117

@@ -120,11 +129,11 @@ Returns the bit at `index`.
120129

121130
##### gascosts
122131

123-
- Fixed: 164
132+
- Fixed: **164**
124133

125134
***
126135

127-
### <a name="bitSet"/>bitSet(uint, uint8)
136+
### bitSet(uint, uint8)
128137

129138
`function bitSet(uint, uint8) internal pure returns (bool)`
130139

@@ -142,11 +151,11 @@ Check if the bit at `index` is set.
142151

143152
##### gascosts
144153

145-
- Fixed: 170
154+
- Fixed: **170**
146155

147156
***
148157

149-
### <a name="bitEqual"/>bitEqual(uint, uint, uint8)
158+
### bitEqual(uint, uint, uint8)
150159

151160
`function bitEqual(uint, uint, uint8) internal pure returns (bool)`
152161

@@ -165,11 +174,11 @@ Checks if the bit at `index` in `self` is the same as the corresponding bit in `
165174

166175
##### gascosts
167176

168-
- Fixed: 184
177+
- Fixed: **184**
169178

170179
***
171180

172-
### <a name="bitAnd"/>bitAnd(uint, uint, uint8)
181+
### bitAnd(uint, uint, uint8)
173182

174183
`function bitAnd(uint, uint, uint8) internal pure returns (uint8)`
175184

@@ -188,11 +197,11 @@ Calculates the bitwise `AND` of the bit at position `index` in `self` and the co
188197

189198
##### gascosts
190199

191-
- Fixed: 178
200+
- Fixed: **178**
192201

193202
***
194203

195-
### <a name="bitOr"/>bitOr(uint, uint, uint8)
204+
### bitOr(uint, uint, uint8)
196205

197206
`function bitOr(uint, uint, uint8) internal pure returns (uint8)`
198207

@@ -211,11 +220,11 @@ Calculates the bitwise `OR` of the bit at position `index` in `self` and the cor
211220

212221
##### gascosts
213222

214-
- Fixed: 178
223+
- Fixed: **178**
215224

216225
***
217226

218-
### <a name="bitXor"/>bitXor(uint, uint, uint8)
227+
### bitXor(uint, uint, uint8)
219228

220229
`function bitXor(uint, uint, uint8) internal pure returns (uint8)`
221230

@@ -234,11 +243,11 @@ Calculates the bitwise `XOR` of the bit at position `index` in `self` and the co
234243

235244
##### gascosts
236245

237-
- Fixed: 178
246+
- Fixed: **178**
238247

239248
***
240249

241-
### <a name="bits"/>bits(uint, uint8, uint16)
250+
### bits(uint, uint8, uint16)
242251

243252
`function bits(uint, uint8, uint16) internal pure returns (uint)`
244253

@@ -264,11 +273,11 @@ To get all the bits: `self.bits(0, 256)`
264273

265274
##### gascosts
266275

267-
- Fixed: 330
276+
- Fixed: **385**
268277

269278
***
270279

271-
### <a name="highestBitSet"/>highestBitSet(uint)
280+
### highestBitSet(uint)
272281

273282
`function highestBitSet(uint) internal pure returns (uint8)`
274283

@@ -288,12 +297,12 @@ Calculates the index of the highest bit set in `self`.
288297

289298
##### gascosts
290299

291-
- For highest bit set == 0: 2845
292-
- For highest bit set == 31: 3759
300+
- For highest bit set == 0: **2845**
301+
- For highest bit set == 31: **3759**
293302

294303
***
295304

296-
### <a name="lowestBitSet"/>lowestBitSet(uint)
305+
### lowestBitSet(uint)
297306

298307
`function lowestBitSet(uint) internal pure returns (uint8)`
299308

@@ -313,6 +322,6 @@ Calculates the index of the lowest bit set in `self`.
313322

314323
##### gascosts
315324

316-
- For lowest bit set == 0: 2181
317-
- For lowest bit set == 31: 3095
325+
- For lowest bit set == 0: **2181**
326+
- For lowest bit set == 31: **3095**
318327

0 commit comments

Comments
 (0)