Hello Folks,
I am trying read a double value from MS SQL server table and to write it in a CSV file on UNIX. For converting that double value I have used DFloatToStringNoExp() function.
I have defined the scale to maximum of the values in that attribute.
I am getting some extra digits (not always same) at the end of number ..
i.e.
e.g. input - 0.880899999884498
output of function is - 0.88089999988449819
data type of input column is Double(15) and output is varchar(100).
Please suggest how to get rid of extra added digits.
Thanks & Regards,
Amarnath
Double to varchar conversion
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
It's a bit of a kluge, but the following will work. Stage variable svStringValue contains the raw result of the DFloatToStringNoExp() function.
If you know that the value is always between 0 and 1, you could go with
Code: Select all
svStringValue <== DFloatToStringNoExp(InLink.TheDecimal)
Field(svStringValue, ".", 1, 1) : "." : Left(Field(svStringValue, ".", 2, 1), 15)
Code: Select all
Left(DFloatToStringNoExp(InLink.TheDecimal),17)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.