Computer Science Canada Formatting Numbers For Output |
Author: | ClayWall [ Fri Jan 02, 2009 10:54 pm ] | ||
Post subject: | Formatting Numbers For Output | ||
I wanted to output some numbers with commas separating every third digit as is the way numbers are commonly formatted. I use one parameter to collect the number to be formatted. Then in reverse I put a comma after every third number. After that I reversed the whole number to read correctly. This creates a way of outputting a number to be visually appealing but does not change a variables value, so the number can be continually formatted. This can even be used with Font.Draw.
This is nothing special, but I thought it might just be what some people were looking for in their programs. EDIT: Had to add a check to make sure a comma was not added to the beginning of the number being formatted. |