‎2012 May 28 10:15 AM
Dear Experts,
Really really appreciate if you could kindly help and share a glimpse on light on the following question:
May I know why for the same number with decimal, e.g. '35.54', can yield different result if I'm using different type of variable?
Below are the my source code and the result.
DATA: float type f,
pn type p decimals 2.
float = '35.54'.
pn = '35.54'.
write: / float.
write: / pn.
Millions Thanks!
‎2012 May 28 10:26 AM
Message was edited by: Rob Burbank
‎2012 May 28 10:27 AM
Hii ,
Since Float will display as 3,55399999999999E+01 as 3.5 * 10 ( power of 1) which is equivalent answer to the value. Since Float doesn't allow decimals.
If you used Packed Numbers, decimal point is fixed to places it would give you approx value. Here its 2 places so it would give the required .
try to use new keywords such as 'DECFLOAT16' and 'DECFLOAT32' which is a mixture of both decimal float number.
for further reference please try to read CD205 Advance ABAP topics for futher information.
‎2012 May 28 10:32 AM
In computer arithmetic, only integer calculations are accurate, every other operation will round the results. Even a move is rounding the result.
- type p decimals 2. is actually an integer, with a virtual decimal position, no rounding.
- float is not an integer so the default value was converted and rounded.
Regards,
Raymond
‎2012 May 28 11:45 AM
Hi,
‎2012 May 28 12:09 PM
Hi,
The difference is as:
<< Moderator message - Cut and paste response from http://scn.sap.com/thread/542914 removed and points unassigned. Plagiarism is not allowed in SCN >>
For further information please refer the folowing threads
http://scn.sap.com/thread/1497542
Point begging also removed.
Regards
Resh
Message was edited by: Rob Burbank