Issue with rounding inside a custom tool
I want to create a custom tool to format a number. I am working with the GeoGebra construction shared by @mathmagic in the post:
https://help.geogebra.org/t.... This construction allows to group the digits of an integer number.
I am adding the ability to use different decimal separators, to use different thousand separators, to round to a given number of decimal places, and to work with negative numbers.
The custom tool is FormatNumber(number to format, number of decimal places, decimal separator (text), thousands separator (text))
However, I am facing an issue:
The intermediate object element2 is truncated to two decimal places when the tool works. So, the final tool always truncates the result to two decimal places when the number for rounding is greater than two. Before creating and applying the custom tool, the result has the wanted number of decimal places.
Could you help me to fit the result to the input value for decimals?
I know the formulas are no good: there are many objects, several formulas are not efficient.
I have created two intermediate tools to check where is the problem: textFractionalTool and Element2Tool. The arguments of both tools are the number to format and the number of decimal places.
Red objects: unwanted rounding
- example objects: outputs of the tools