Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Decimal Floating Point

Former Member
0 Kudos

The value of <LFS_DECFLOAT> is correct whereas <LFS1_DECFLOAT> looks to be incorrect. Can anyone explain why the value of <LFS_DECFLOAT> GT 1?

Many Thanks, Tanmoy

3 REPLIES 3

0 Kudos

May be u use the same memory space. Try this

DATA: lv_dec16 TYPE DECFLOAT16,
       lv_dec34 TYPE decfloat34,
       lv_dec34_2 TYPE decfloat34.

FIELD-SYMBOLS: <lf_dec> TYPE decfloat,
                <lf_dec1> TYPE decfloat.

   lv_dec34 = 1 / 9.
   lv_dec34_2 = 1 / 9.
   ASSIGN lv_dec34 TO <lf_dec>.
   ASSIGN lv_dec34_2 TO <lf_dec1> CASTING TYPE decfloat34."changed to 34
   IF sy-subrc IS INITIAL.

   ENDIF.


Regards,

Alberto Montes

0 Kudos

I don't understand why does the value get changed? It should still be 0.111111111111111 at most.

Thanks, Tanmoy

0 Kudos

DATA: lv_dec16 TYPE DECFLOAT16,
       lv_dec34 TYPE decfloat34,
       lv_dec34_2 TYPE decfloat34.

FIELD-SYMBOLS: <lf_dec> TYPE decfloat,
                <lf_dec2> TYPE decfloat.

   lv_dec34 = 1 / 9.
   lv_dec16 = 1 / 9.
   ASSIGN lv_dec34 TO <lf_dec>.
   ASSIGN lv_dec16 TO <lf_dec2>.
   IF sy-subrc IS INITIAL.

   ENDIF.


I think you cant do that, because decfloat do the conversion automaticly. So if you have a decfloat16 variable, the assign to decfloat do the conversion decfloat16->decfloat. And the same with decfloat34. I supose you force the conversion of decfloat to decfloat16, first the assign to decfloat from decfloat34 and then the forced conversion to decfloat16. The data changes because you are watching the number of a decfloat like a decfloat16.