Number Formatting
Moderators: chulett, rschirm, roy
Number Formatting
I am needing to convert two type of numbers within a DS Server job.
Firstly, I need to convert a number (e.g. 5.5) to the following format - NNNN.NNNN (in other words 5.5 would equal 0005.5000.
Secondly, I need to convert a number (e.e. 15.50) to the following format - NNNNNNNNNNNNNNNNNN (in other words 15.50 would equal 000000000000001550.
And finally, if my number is negative, how do I ensure that the '-' sign appears at the front ? I other words, -5.5 appears as -0005.5000 and not 000-5.5000.
Any suggestions ?
Firstly, I need to convert a number (e.g. 5.5) to the following format - NNNN.NNNN (in other words 5.5 would equal 0005.5000.
Secondly, I need to convert a number (e.e. 15.50) to the following format - NNNNNNNNNNNNNNNNNN (in other words 15.50 would equal 000000000000001550.
And finally, if my number is negative, how do I ensure that the '-' sign appears at the front ? I other words, -5.5 appears as -0005.5000 and not 000-5.5000.
Any suggestions ?
-
- Participant
- Posts: 232
- Joined: Fri Sep 30, 2005 4:52 am
- Contact:
You can use the FMT function, check your online help. Off the top of my head there may not be a formatting option for a leading minus sign. If not, simply check if your value is < 0 and concatenate it on the front of your output field if so.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Use field along with the fmt function. Basically strip the contents before and after the decimal point, format it using the fmt function and then concatenate it back together. Not a very sleek solution but will get your things rolling.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
I have used the following:
and
And for a value of 79.12 this gives me two values : 79 and 12.
When I then do
where LGD is the StageVariable name for the first bit of code above, I get the following output :
Any ideas ?
Code: Select all
Field(ResultsWrite2.LGD_CALC_VAL, ".", 1, 1)
Code: Select all
Field(ResultsWrite2.LGD_CALC_VAL, ".", 2, 1)
When I then do
Code: Select all
Fmt(LGDFirst, "R'0'4")
And I was hoping to see 0079'''''
Any ideas ?
the fmt code is
Code: Select all
Fmt(LGDFirst, "4'0'R")
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Code: Select all
Fmt(Fmt(ResultsWrite2.LGD_CALC_VAL,"7'0'R"),"9'0'L")
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers