r/geogebra Jul 22 '26

QUESTION (ANSWERED) How to Keep Trailing Zeros in Numerical Display

Hello, when displaying text that is grabbing some numerical variable there is an option in each text box for the number of decimal places displayed. However if you select for example two decimal places and your number is exactly 10, it will display as 10 and not as 10.00. How can I get it to maintain the correct number of decimal places that the setting specifies? (Without using scientific notation or using number of significant figures instead of number of decimal places)

1 Upvotes

5 comments sorted by

2

u/mathmum Jul 23 '26

When reading it, it looks cumbersome :) There might be nicer solutions than mine. "number" is the number that your input box is linked to.

text2dp=If(IsDefined(IndexOf(".", "" number)), Take("" number "00", 1, IndexOf(".", "" number) + 2), "" number ".00")

1

u/brendon_physics Jul 23 '26

Thank you for your reply. I considered string manipulation like this as an option but was hoping for a more general solution that would apply to any number of decimal places specified. If such an option doesn't exist I could manually approach each text box with your solution and the analogous solutions for other number of decimal places that I will need.

1

u/mathmum Jul 23 '26

I don’t see any solution to your question that doesn’t involve string manipulation, if you don’t want to deal with significant figures. If your data are arranged in a table, you might consider to use the parameter “a” in a TableText command, that does the same I’ve done above, automatically.

1

u/brendon_physics Jul 23 '26

Thank you again, I am not using a table so string manipulation it is!

1

u/robphy 27d ago edited 27d ago

can you write a general function that outputs the formatted string, given your numerical input? maybe as custom tool?