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

math: inf,nan,fmod for the JS backend (#11246)

This commit is contained in:
playX
2021-08-20 01:14:49 +03:00
committed by GitHub
parent 70a658a265
commit 1570e613b5
10 changed files with 812 additions and 34 deletions

18
vlib/math/evaluate.v Normal file
View File

@ -0,0 +1,18 @@
module math
// Provides functions that don't have a numerical solution and must
// be solved computationally (e.g. evaluation of a polynomial)
pub fn polynomial(z f64, coeff []f64) f64 {
n := coeff.len
if n == 0 {
return 0.0
}
mut sum := coeff[n - 1]
for i := n - 1; i >= 0; i-- {
sum *= z
sum += coeff[i]
}
return sum
}