Math Function: make 5 appear as 05

probably pretty simple.

I have a value that's minutes.seconds which presents like 5.55
i would like to keep my 0 placeholder - so 5.5 (5 minutes 5 seconds) would present like 5.05

I could do the old if less than 10 join "0" & seconds as a string.
but that just feels . . . silly

split text at .(dot)
if the length of the 2nd item is less than 2 then add zero to prefix else use it same

EDIT: (can be simplify this too)

this is how im doing it now for this particular scenario.
just figured there was something simplier.

double 00

your way of adding a zero to the end is sound for sure.
I guess this is how i added 0 to the beginning
so 3mph would be 003mph.

this is driven by textbox formatting - then everything is in a nice line regardless of values.

Try this App Inventor Code Snippets | Pura Vida Apps


that feels way less silly, thank you

If you are designing a speedometer this tutorial might be appropriate

Its just a background thing that saves in a data log file - although, making analog gauges virtual screen style is on my list of to do's. Ill have to take a look, thank you for your input.

edit: lol I actually recognize your link as something I had previously looked into and saved.
small world

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.