global decimal limit / precision
Hey,
Is there a way to set the global decimal limit / precision for all results ( not only BigNumbers ).
At the moment i am using your library to parse/evaluate a string with the results of a form to calculate some stuff, but i would like the results to be more "readable"
The full scenario: i have 5 standard form fields in the frontend (which will fill up the "scope") and i am calculating the distance like this :
calculated-distance=sum(hours-field hours to seconds, minutes-field minutes to seconds, seconds-field seconds to seconds)/sum(minutes-pace-field minutes to seconds, seconds-pace-field seconds to seconds)
calculated-distance-miles=calculated-distance km to miles
// taken from the user input
scope = {
'hours-fields' = 1,
'minutes-field' = 56,
'seconds-field' = 3,
'minutes-pace-field' = 5,
'seconds-pace-field' = 30,
}
//calculated values after user fills up the inputs using math.evaluate( formula, scope )
calculated-distance = 21.10 KM
calculated-distance-miles = 13.110932156207747 miles
and I would like it to be formatted like this
21.10 KM - 13.11 miles
Thanks for your patience 👍
You can use a function like math.format to format any outputs in a standardized for with limited precision for example: https://mathjs.org/docs/reference/functions/format.html
Hey thanks, got it working by formatting the result from the evaluation!
👍