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

Convert float to a numeric with 3 decimals

Former Member
0 Likes
14,515

Hi,

How can I convert a float number to a numeric number with 3 decimals?

Tks,

Daniela

1 ACCEPTED SOLUTION
Read only

Former Member
5,719

hi Daniela,

Declare it as type <b>P</b>

i.e,

Data : v_float type f,

v_dec type p decimals 3.

v_dec = v_float.

write : v_float, v_dec.

Regards,

Santosh

hi Daniela,

Declare it as type <b>P</b>

i.e,

Data : v_float type f,

v_dec type p decimals 3.

v_dec = v_float.

write : v_float, v_dec.

Regards,

Santosh

8 REPLIES 8
Read only

Former Member
5,720

hi Daniela,

Declare it as type <b>P</b>

i.e,

Data : v_float type f,

v_dec type p decimals 3.

v_dec = v_float.

write : v_float, v_dec.

Regards,

Santosh

Read only

0 Likes
5,719

Santosh

I tried to do that but it happens a sintaxe error when I use MOVE Command "v_test muat be a character-type field".

regards,

Daniela

Read only

Former Member
0 Likes
5,719

HI,

data: var1 type p decimals 3.

Regards

Laxmi.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
5,719

Just move from f to p type fields.



data: f type f value '12345.13254'.
data: p type p decimals 3.

p = f.

write:/ p.


Regards,

Rich Heilman

Read only

0 Likes
5,719

hi Daniela,

I have tried here and i have pasted the code it was not giving me any error did you declare the parameters as i have mentioned above.

Read only

0 Likes
5,719

Santosh

It works!

Thak you very much!

Read only

Former Member
0 Likes
5,719

hi daniela,

data f1 type f value 180.

data f2 type p decimals 3.

move f1 to f2.

write: / f1, f2.

Read only

antony_paul2
Active Participant
0 Likes
5,719

Hi santhosh,

Thanks for your help, its working for me..

Regards.

Antony