Alright, I made an action for this, using the more elegant Mathf.Repeat function. The other way you suggest is also included in a comment line. You can simply switch to this, however both give identical results, including this tiny caveat: because the trick uses rounding in either way, the outcome might be off by a very tiny fraction. In my test, 23.13742 returns 0.1374207. Or 23.13 returns 0.1299992 (i.e. off by 0.0000008).

There are complicated ways to prevent this (counting digits, then applying the rounding, using a suitable rounding strategy), but I think some rouding needs to be applied anyway if the number is used for a User Interface, and that should be an extra step.