Skip to Content

How to check if a number has a floating point?

Hi all!

How do I check if a number has floating point (decimal number)?

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Dec 18, 2008 at 12:35 PM

    there are several ways: one would be to take the integer part of the number and check if it is equal to the orignal value.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 12:35 PM

    Use CA statement.

    Check this:

    DATA: num(10) TYPE c VALUE '121212.00'.
    IF num CA '.'.
      WRITE: 'YES'.
    ELSE.
      WRITE: 'NO DECIMAL'.
    ENDIF.

    or you can do like this also.

    DATA: num1 TYPE p decimals 2 VALUE '121212'.
    DATA num2 TYPE i.
    num2 =  num1.
    IF num2 EQ num1.
      WRITE: 'NO DECIMAL'.
    ELSE.
      WRITE: 'YES'.
    ENDIF.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 12:50 PM

    Hi,

    Try this,

    data : var(10) TYPE c VALUE '1465.76'.

    find '.' in var.

    if sy-subrc = 0.

    *check sy-subrc and do whatever u want

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.