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 Scientific Notation

Former Member
0 Likes
4,909

Hey guys

I'd like to convert 3,0000000000000000E+04 (type CHAR 12) to its value 30000 (i.e. 3 * 10^4). I'm having trouble dealing with the comma and I'm not sure how to convert this. Can anyone help me?

6 REPLIES 6
Read only

FredericGirod
Active Contributor
0 Likes
3,335

Do you simply try

data lv_my_data type i.
lv_my_data =  lv_my_exp. 
Read only

0 Likes
3,335

Yes, it doesn't recognizes as a number

Read only

0 Likes
3,335

Google said

CHAR_FLTP_CONVERSION

FLTP_CHAR_CONVERSION

Read only

Sandra_Rossi
Active Contributor
3,335

What target type do you expect for 30000 ? Let's suppose decfloat16...

Basic implicit type conversion stuff handled natively by ABAP (cf ABAP documentation ? Conversion Rules for Elementary Data Objects ? Character-Like Source Fields ? S... : "The source field must contain a number in mathematical, SCIENTIFIC, or commercial notation"):

DATA(string) = |3,0000000000000000E+04|.
REPLACE ALL OCCURRENCES OF ',' IN string WITH '.'.
DATA(number) = CONV decfloat16( string ).

NB: I don't understand how 3,0000000000000000E+04 (22 characters) can be stored in only 12 characters, or is it a typographic error?

Read only

3,335

Is it not the packet type ? 1/2 byte to store a the value so 12 bytes represents 24 values

Read only

0 Likes
3,335

The OP says "type CHAR 12", I don't see "P" or "PACKED" in the question.