mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-04 00:44:27 +00:00
1e862511aa
* adding deposit contract * Adding bindings * remove unused info * shifting deploy function over * new changes * fixing tests and moving log utils to contract package * new changes,helpers, fixing tests * fix failing test * readme * contract change * changes to contract * new changes,helpers, fixing tests * missing files * adding constructor to contract * lint * updating with spec * finally got it fixed * add in deposit arguments * new changes * all tests pass * addresing raul's and terence's comments * remove vrc
42 lines
782 B
Go
42 lines
782 B
Go
package mathutil
|
|
|
|
// IntegerSquareRoot defines a function that returns the
|
|
// largest possible integer root of a number.
|
|
func IntegerSquareRoot(n uint64) uint64 {
|
|
x := n
|
|
y := (x + 1) / 2
|
|
|
|
for y < x {
|
|
x = y
|
|
y = (x + n/x) / 2
|
|
}
|
|
return x
|
|
}
|
|
|
|
// CeilDiv8 divides the input number by 8
|
|
// and takes the ceiling of that number.
|
|
func CeilDiv8(n int) int {
|
|
ret := n / 8
|
|
if n%8 > 0 {
|
|
ret++
|
|
}
|
|
|
|
return ret
|
|
}
|
|
|
|
// IsPowerOf2 returns true if n is an
|
|
// exact power of two. False otherwise.
|
|
func IsPowerOf2(n uint64) bool {
|
|
return (n & (n - 1)) == 0
|
|
}
|
|
|
|
// PowerOf2 returns an integer that is the provided
|
|
// exponent of 2. Can only return powers of 2 till 63,
|
|
// after that it overflows
|
|
func PowerOf2(n uint64) uint64 {
|
|
if n >= 64 {
|
|
panic("integer overflow")
|
|
}
|
|
return 1 << n
|
|
}
|