mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
math.bits: add some more helpers, to be used in upcoming biginteger
This commit is contained in:

committed by
Alexander Medvednikov

parent
5a03eaca89
commit
d80a3365c4
@ -5,13 +5,12 @@
|
||||
module rand
|
||||
|
||||
import(
|
||||
math
|
||||
math.bits
|
||||
encoding.binary
|
||||
)
|
||||
|
||||
pub fn int_u64(max u64) u64? {
|
||||
// bitlen := int(math.floor(math.log2(f64(max))+1))
|
||||
bitlen := int(math.floor(math.log(f64(max))/math.log(2)) + 1)
|
||||
bitlen := bits.len64(max)
|
||||
if bitlen == 0 {
|
||||
return u64(0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user