The xojo IDE comes an example tutorial called Evaluator that allows you to use the xojo script to evaluate mathematical expressions.
If I run 100/541 it gives me a result of 0.2217295 when in reality it is 0.22172949. That is, it rounds the last decimal for me. Is there an easy way to prevent it from rounding decimals?
Thanks
You can change the XojoScript to do what you want.
For simplicity the XojoScript code in Evaluator uses the Str function is used to convert the value to a String, which limits the precision. But you could change that to use Format with a format string specifying the number of decimals.
Or you could save the output back to both a String and the actual Double and then pull out the one you want. This modified sample project shows how that might work:
Evaluator2.xojo_binary_project.zip (12.8 KB)
2 Likes
Thanks Paul. Since DoubleValue instead of Str works fine for my needs.
I’ve also tried with Format(DoubleValue,“-###,###.################” but it does extranger things. After a double decimal 0 calculating more decimals.
I’m sticking with the option of Double value directly without a string