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

math: add round_sig function for f64 (#14997)

This commit is contained in:
CC
2022-07-09 01:41:58 -06:00
committed by GitHub
parent c5a290ffc6
commit 7e1c45ab44
2 changed files with 40 additions and 0 deletions

View File

@ -808,6 +808,17 @@ fn test_round() {
}
}
fn fn_test_round_sig() {
assert round_sig(4.3239437319748394, -1) == 4.3239437319748394
assert round_sig(4.3239437319748394, 0) == 4.0000000000000000
assert round_sig(4.3239437319748394, 1) == 4.3000000000000000
assert round_sig(4.3239437319748394, 2) == 4.3200000000000000
assert round_sig(4.3239437319748394, 3) == 4.3240000000000000
assert round_sig(4.3239437319748394, 6) == 4.3239440000000000
assert round_sig(4.3239437319748394, 12) == 4.323943731975
assert round_sig(4.3239437319748394, 17) == 4.3239437319748394
}
fn test_sin() {
for i := 0; i < math.vf_.len; i++ {
f := sin(math.vf_[i])