string to decimal conversion
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 98
- Joined: Thu Feb 05, 2009 1:14 am
- Location: visakhapatnam
- Contact:
string to decimal conversion
Hi,
HI,
I have a varchar(18) value say 17826.12 coming from source now since this value is greater than 10000.00 the target value is losing its least significant values my target value is coming as 17826.1,the values below than 10000.00 coming from source is absolutely fine.
my code is as follows
String to Decimal(var1)/100-->VAR2
if len(VAR2)='0' then '0' else DecimaltoString(VAR2,"suppress_zero")
CAN ANYONE SORT OUT THIS ISSUE FOR ME.
Thanks
Sunitha
HI,
I have a varchar(18) value say 17826.12 coming from source now since this value is greater than 10000.00 the target value is losing its least significant values my target value is coming as 17826.1,the values below than 10000.00 coming from source is absolutely fine.
my code is as follows
String to Decimal(var1)/100-->VAR2
if len(VAR2)='0' then '0' else DecimaltoString(VAR2,"suppress_zero")
CAN ANYONE SORT OUT THIS ISSUE FOR ME.
Thanks
Sunitha
-
- Participant
- Posts: 98
- Joined: Thu Feb 05, 2009 1:14 am
- Location: visakhapatnam
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
What you are describing makes perfect sense, assuming that VAR2 has datatype Decimal(18,2) - you left out the word "Decimal".
You are dividing by 100, to produce a decimal number with a scale of 4, but then loading it into a decimal data type with a scale of only 2. Therefore the two least significant digits have to disappear. Whether the result is rounded or truncated depends on your rtype argument.
You are dividing by 100, to produce a decimal number with a scale of 4, but then loading it into a decimal data type with a scale of only 2. Therefore the two least significant digits have to disappear. Whether the result is rounded or truncated depends on your rtype argument.
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.
-
- Participant
- Posts: 98
- Joined: Thu Feb 05, 2009 1:14 am
- Location: visakhapatnam
- Contact:
-
- Participant
- Posts: 98
- Joined: Thu Feb 05, 2009 1:14 am
- Location: visakhapatnam
- Contact:
-
- Participant
- Posts: 98
- Joined: Thu Feb 05, 2009 1:14 am
- Location: visakhapatnam
- Contact:
-
- Participant
- Posts: 98
- Joined: Thu Feb 05, 2009 1:14 am
- Location: visakhapatnam
- Contact:
-
- Participant
- Posts: 98
- Joined: Thu Feb 05, 2009 1:14 am
- Location: visakhapatnam
- Contact:
-
- Participant
- Posts: 98
- Joined: Thu Feb 05, 2009 1:14 am
- Location: visakhapatnam
- Contact: