Application Development and Automation 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: 
Read only

Floating point calculation

Former Member
0 Likes
1,299

Hi all,

I have a field ATFLV of type FLTP length 16 and decimals 16. This field has a value 1.000000000000000E+03. I want to multiply this value with 0.022 and take that value into another field let us say ATFLV1 of same type as ATFLV.

And also, I want the value in ATFLV1 to be taken into another field ATWRT of type Character and length 30.

PLease help. Waiting for replies. Thanks

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,180

Try this.




report zrich_0001.


data: ATFLV type cawn-ATFLV value '1.000000000000000E+03',
      atwrt type cawn-atwrt,
      p type  p decimals 3.


 p = atflv * '.022'.

 atwrt = p.

 write:/ atwrt.

Regards,

Rich Heilman

9 REPLIES 9
Read only

Former Member
0 Likes
1,180

atflv1 = atflv * 0.022.

write atflv1 to atwrt.

Regards,

Ravi

Read only

0 Likes
1,180

It throws and error saying 022 not defined.

Read only

Former Member
0 Likes
1,180

Hi,

atflv1 = atvlv * 0.022

move atflv1 to atwrt.

regards,

keerthi.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,181

Try this.




report zrich_0001.


data: ATFLV type cawn-ATFLV value '1.000000000000000E+03',
      atwrt type cawn-atwrt,
      p type  p decimals 3.


 p = atflv * '.022'.

 atwrt = p.

 write:/ atwrt.

Regards,

Rich Heilman

Read only

0 Likes
1,180

Rich,

It prints the value in atwrt as 22.000. I want the value in atwrt with out decimals. So it should be only '22'. how can I do this. Waiting..........

Read only

0 Likes
1,180

Ok....




report zrich_0001.


data: ATFLV type cawn-ATFLV value '1.000000000000000E+03',
      atwrt type cawn-atwrt,
      p type  p decimals 3.


 p = atflv * '.022'.

<b> atwrt = ceil( p ).</b>

 write:/ atwrt.

Regards,

Rich Heilman

Read only

0 Likes
1,180

Or use an INT instead of packed field.



report zrich_0001.


data: ATFLV type cawn-ATFLV value '1.000000000000000E+03',
      atwrt type cawn-atwrt,
<b>      i type  i .</b>


<b>i = atflv * '.022'.</b>

<b> atwrt = i.</b>

 write:/ atwrt.

Regards,

Rich Heilman

Read only

0 Likes
1,180

Rich,

In your code what I am doing is:

data: ATFLV type cawn-ATFLV value '1.000000000000000E+03',

atflv1 type cawn-atflv,

atwrt type cawn-atwrt.

atflv1 = atflv * '.022'.

Now the value in atflv1 is '2.200000000000000E+01',

Now I want this value in the field ATWRT as '22'.

Please help.

Read only

0 Likes
1,180

Just change the ATFLV1 field to an int.



data: ATFLV type cawn-ATFLV value '1.000000000000000E+03',
<b>atflv1 type i,</b> 
atwrt type cawn-atwrt.

atflv1 = atflv * '.022'.

<b>atwrt = atflv1.</b>




Regards,

Rich Heilman