Skip to content

Commit

Permalink
minor readability-fixes for Byte
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed May 6, 2024
1 parent e2c1559 commit 0a354ff
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions uint256.go
Original file line number Diff line number Diff line change
Expand Up @@ -1240,16 +1240,16 @@ func (z *Int) Xor(x, y *Int) *Int {
// if n >= 32, z is set to 0
// Example: z=5, n=31 => 5
func (z *Int) Byte(n *Int) *Int {
// in z, z[0] is the least significant
//
if index, overflow := n.Uint64WithOverflow(); !overflow && index < 32 {
number := z[4-1-index/8]
offset := (index & 0x7) << 3 // 8 * (index % 8)
z[0] = (number >> (56 - offset)) & 0xff
z[3], z[2], z[1] = 0, 0, 0
return z
index, overflow := n.Uint64WithOverflow()
if overflow || index >= 32 {
return z.Clear()
}
return z.Clear()
// in z, z[0] is the least significant
number := z[4-1-index/8]
offset := (index & 0x7) << 3 // 8 * (index % 8)
z[0] = (number >> (56 - offset)) & 0xff
z[3], z[2], z[1] = 0, 0, 0
return z
}

// Exp sets z = base**exponent mod 2**256, and returns z.
Expand Down

0 comments on commit 0a354ff

Please # to comment.