ToString for decimal with round or without round?
Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Cy_Liu
5 - Atom
‎08-24-2023
05:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
We have an case
22.33/2 = 11.165
ToString(22.33/2 ,2) = 11.16
22.67/2 = 11.335
ToString(22.67/2,2) = 11.34
I am confuseing.
2 REPLIES 2
Prometheus
12 - Quasar
‎08-24-2023
05:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
FinnCharlton
13 - Pulsar
‎08-24-2023
06:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This is pretty strange behaviour, definitely won't be trusting this function for rounding in the future:
As you can see above, the function rounds 0.155 downwards to 0.15, but rounds 0.165 upwards to 0.17.
It isn't consistent with which hundredths it rounds up or down, as 11.165 is rounded down.
The solution is to use the Round function before wrapping in the ToString function, like I have in the 'Round first' field in the picture. Use a formula like this:
ToString(round([Number],0.01))
