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 string to floating-point

Former Member
0 Likes
2,613

Hi all,

..very basic question, but I tryed it for hours and only received short-dumps

<b>How can I convert a string into a floating-point number?</b>

Kind regards,

Stefan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,556

Hii

<b>data : a type f,

s type string value '1.023'.

write s to a . " this statement converts string to float

write:/ a .</b>

Regards

11 REPLIES 11
Read only

Former Member
0 Likes
1,556

hi

try this

to convert string to float.

data : a type f,

s type string value '1.023'.

a = s.

write 😕 a.

to convert float to string.

data : a type f value '1.023',

s type string.

s = a.

write : s.

Read only

suresh_datti
Active Contributor
0 Likes
1,556

try this..


report  zfloat                                  .
data: y_pack(16) type c,
      w_float type f.
*----------------------------------------------------------------------

pack '1234' to y_pack.
w_float = y_pack.

write:/ w_float.

Regards,

Suresh Datti

Read only

Former Member
0 Likes
1,556

use MOVE V_CHAR TO V_FLOAT.

Read only

0 Likes
1,556

<b>hi Use MOVE OR ASSIGNMENT FOR THE SAME</b>

i.e, Data : P_ FLOAT TYPE F,

P_STRING TYPE C.

P_STRING = P_FLOAT.

Regards,

Santosh

Read only

0 Likes
1,556

I already tryed

MOVE

but it dídn't work.

Here is my more detailed problem-description:

-db-table with field (type DEC)

-string with value 0,035

How can i write it in the table?

Read only

0 Likes
1,556

hi

data : temp_field type f.

s type string .

temp_field = s.

<b>dbtab-field = temp_field.</b>

this works fine

plz reward if useful

Read only

Former Member
0 Likes
1,557

Hii

<b>data : a type f,

s type string value '1.023'.

write s to a . " this statement converts string to float

write:/ a .</b>

Regards

Read only

Former Member
0 Likes
1,556

Thanks, I alreday found my probleM:

I used

3.035

instead of

3,035

.

Now it works. Thanks for your help!

Read only

Former Member
0 Likes
1,556

hi formular

<b>plz check the working of the code before awarding points</b>

@@@the same code has been posted earlier......i guess u hav missed it out

Read only

0 Likes
1,556

i guess you are right

...but only with the <b>bold</b> format, I saw it

Read only

0 Likes
1,556

hi again

make sure that the code sample works & reward accordingly .

regards

ganesh