# 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!

10|10000 characters needed characters exceeded

### Related questions

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.

10|10000 characters needed characters exceeded
• >

> Hello Ricardo,

>

> Plz try this code:

>

>

```> v_int = trunc( v_num ).
>
> IF v_int = v_num.
>   WRITE: ' Number has no floating point '
> ELSE.
>   WRITE: ' Number has floating point '
> ENDIF.
> ```

>

> Hope this is clear.

>

> BR,

> Suhas

Thanks Suhas! I used this and it worked. 😊

• 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

10|10000 characters needed characters exceeded
• 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.