mirror of
https://github.com/vlang/v.git
synced 2025-09-14 09:56:16 -04:00
math.big: make is_power_of_2() be false for negatives (it now matches Julia's ispow2/1) (#24619)
This commit is contained in:
parent
a1c5f41c6b
commit
b19fa76c6e
@ -110,6 +110,7 @@ struct IsXTest {
|
||||
|
||||
// vfmt off
|
||||
const is_power_of_2_test_data = [
|
||||
IsXTest{ "-4", false },
|
||||
IsXTest{ u32(0b110000000000), false },
|
||||
IsXTest{ "537502395172353242345", false },
|
||||
IsXTest{ "590295810358705700000", false },
|
||||
|
@ -1214,7 +1214,7 @@ pub fn (x Integer) is_odd() bool {
|
||||
// is_power_of_2 returns true when the integer `x` satisfies `2^n`, where `n >= 0`
|
||||
@[direct_array_access; inline]
|
||||
pub fn (x Integer) is_power_of_2() bool {
|
||||
if x.signum == 0 {
|
||||
if x.signum <= 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user