Printing a fixed length decimal number
John_B
Posts: 16
Hi,
Is there any routines that print a fixed length signed decimal number.
If so, does the routine take care of the '-' or are positive numbers prefixed with '+' ?
ie.
00000
00005
12345
-0023
Thanks,
Jon
Is there any routines that print a fixed length signed decimal number.
If so, does the routine take care of the '-' or are positive numbers prefixed with '+' ?
ie.
00000
00005
12345
-0023
Thanks,
Jon
Comments
Here's one:
Instead of "i == 1" in the 3rd from the bottom line, put "i < 100000" to get 5 digits, "i < 1000" to get 3 digits, etc.
Note: This will append the minus sign to a fixed length numeric value (like "-001" or "001"). You will need some additional logic to either add an extra digit position if positive or to put out a "+" if positive.
Post Edited (Mike Green) : 10/6/2009 2:43:39 PM GMT
It took a bit of time to realise what was happening, but I have now modified the routine so a variety of number styles can be printed from the calling routines.
Many thanks
Jon