1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: smarter if condition wrapping (#8201)

This commit is contained in:
Lukas Neubert
2021-01-23 09:33:22 +01:00
committed by GitHub
parent 9812230847
commit 8b61891348
65 changed files with 686 additions and 811 deletions

View File

@@ -117,14 +117,12 @@ fn test_str() {
assert big.from_u64(4398046511104).str() == '4398046511104'
assert big.from_int(4294967295).str() == '18446744073709551615'
assert big.from_int(-1).str() == '18446744073709551615'
assert big.from_hex_string('e'.repeat(80)).str() ==
'1993587900192849410235353592424915306962524220866209251950572167300738410728597846688097947807470'
assert big.from_hex_string('e'.repeat(80)).str() == '1993587900192849410235353592424915306962524220866209251950572167300738410728597846688097947807470'
}
fn test_factorial() {
f5 := big.factorial(big.from_u64(5))
assert f5.hexstr() == '78'
f100 := big.factorial(big.from_u64(100))
assert f100.hexstr() ==
'1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000'
assert f100.hexstr() == '1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000'
}

View File

@@ -107,8 +107,8 @@ pub fn ones_count_16(x u16) int {
// ones_count_32 returns the number of one bits ("population count") in x.
pub fn ones_count_32(x u32) int {
return int(pop_8_tab[x >> 24] + pop_8_tab[x >> 16 & 0xff] + pop_8_tab[x >> 8 & 0xff] + pop_8_tab[x &
u32(0xff)])
return int(pop_8_tab[x >> 24] + pop_8_tab[x >> 16 & 0xff] + pop_8_tab[x >> 8 & 0xff] +
pop_8_tab[x & u32(0xff)])
}
// ones_count_64 returns the number of one bits ("population count") in x.