mardi 14 novembre 2017

Set up random tests for a function that minimizes rounding error possibilities (javascript)

I´m currently generating random tests (javascript) in order to create an input array for my function for x-times. The array always has the following order: [string, number, number, number, number, string]. The arrays serve as inputs to a formula that calculates one result out of all array elements. More specifically the formula calculates the calorie requirement of a person based on gender, weight, height, age, activity level. The final result will be rounded to .xx (two decimal digits).

Everything works great but I would like to prevent random test cases leading to a final result of .xx5 in oder to prevent rounding errors at rounding boundaries. I thought about setting up a while loop but I´m not sure how...

here´s the code sample

Any ideas?




Aucun commentaire:

Enregistrer un commentaire