Formatting numbers with 000s separator


oldgrey1

Recommended Posts

Format() is described in the Expressions Chapter->Expression reference->String functions. It also pretty much follows the standard C printf() statement exactly.

No, there is no built in function that displays the thousands separator. You'd have to create your own using script, which shouldn't be too hard. Off the cuff, something like this:

function formatThousands(val)

if (val >= 1000)
   return format("%d",floor(val / 1000)) + "," + format("%.3f",val % 1000)
else
   return format("%.3f",val)
endif

That only works up to 1 million and displays 3 decimals (the "%.3f"). Also, as I said, its off the cuff, so may not work perfectly (for example, won't handle negative values < -1000), but you get the idea.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.