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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
}