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

math: sqrti, powi, factoriali (#12072)

This commit is contained in:
05st
2021-10-08 14:07:44 -05:00
committed by GitHub
parent cd5b304cbf
commit 43931be451
5 changed files with 88 additions and 0 deletions

View File

@ -946,3 +946,15 @@ fn test_large_tan() {
assert soclose(f1, f2, 4e-8)
}
}
fn test_sqrti() {
assert sqrti(i64(123456789) * i64(123456789)) == 123456789
assert sqrti(144) == 12
assert sqrti(0) == 0
}
fn test_powi() {
assert powi(2, 62) == i64(4611686018427387904)
assert powi(0, -2) == -1 // div by 0
assert powi(2, -1) == 0
}