Simplified file structure
This commit is contained in:
parent
cacee7260a
commit
a466281307
219 changed files with 453 additions and 457 deletions
20
src/sizeof/Unsigned.go
Normal file
20
src/sizeof/Unsigned.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package sizeof
|
||||
|
||||
import "math"
|
||||
|
||||
// Unsigned tells you how many bytes are needed to encode this unsigned number.
|
||||
func Unsigned(number uint64) int {
|
||||
switch {
|
||||
case number <= math.MaxUint8:
|
||||
return 1
|
||||
|
||||
case number <= math.MaxUint16:
|
||||
return 2
|
||||
|
||||
case number <= math.MaxUint32:
|
||||
return 4
|
||||
|
||||
default:
|
||||
return 8
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue