Is there a way currently to show optional decimals?
Something like this:
0,0.##
1234 -> 1,234
1234.5 -> 1,234.5
1234.56 -> 1,234.56
1234.567 -> 1,234.57
etc.
I just tried to do 0.# today expecting that exact functionality, didn't seem to work.
I was trying to format the values [8, 8.1, 8.2, 8.299999999999999] as 8km, 8.1km 8.2km and 8.3km respectively
The syntax is like so: 0[.]0.
@jakeorr
According the docs:
10000.1234
'0[.]00000'
10000.12340
Looks like that it is adding 0's instead of removing them.
Ah, I see what you mean when you say optional.
When I have used it in the past I was more worried about showing decimals if they exist.
1000.12 would show 1000.12, but 99 would show 99 not 99.00.
try: 0,0.[00]
what hartadi said 0,0.[00]
Not what the OP was looking for, but if anyone else stumbles on this looking for a way to optionally not show cents with currency, 0,0[.]00 worked best for me:
0,0[.]00
1.55 => 1.55
1.5 => 1.50
1 => 1
0,0.[00]
1.55 => 1.55
1.5 => 1.5
1 => 1
Most helpful comment
try: 0,0.[00]