2

I'm newbie to abap, please let me know ,the use of ceil and floor function in abap.

6 Answers 6

6

To add to Hyperboreus' answer, this is strictly speaking not an ABAP question, as the ceiling and floor functions are generic mathematical functions included in other languages too.

You can try it for yourself with the following ABAP code to get a hands-on understanding:

data: v type p decimals 1.
data: c type i.
data: f type i.

v = '8.2'.

c = ceil( v ).
f = floor( v ).
write: c, f.
5

Unfortunatly I do not know a thing about abap, but ceil and floot are generally defined as follows:

The floor of a float value is the next lowest integer.

The ceiling of a float value is the next highest integer.

Exempli gratia:

ceil (4.1) = 5
floor (4.1) = 4
2

FLOOR returns the nearest Smallest integer
CEIL returns the nearest Largest Interger

0

CEIL has the meaning of rounding the number up - to the ceiling...
FLOOR has the meaning of rounding the number down - to floowr...

as previously answered:
eg. value 4.1 will be:

floor -> 4.0
ceil -> 5.0

0

ceil is return Smallest integer value.

floor is return Largest integer value.

Example: Mathematical functions for all Numeric Data Types

DATA n TYPE p DECIMALS 2.
DATA m TYPE p DECIMALS 2 VALUE '-5.55'.
n = abs( m ).  WRITE:  'ABS: ', n.
n = sign( m ). WRITE: / 'SIGN: ', n.
n = ceil( m ). WRITE: / 'CEIL: ', n.
n = floor( m ). WRITE: / 'FLOOR:', n.
n = trunc( m ). WRITE: / 'TRUNC:', n.
n = frac( m ). WRITE: / 'FRAC: ', n.
The output appears as follows:
ABS: 5.55
SIGN:  1.00-
CEIL:  5.00-
FLOOR: 6.00-
TRUNC: 5.00-
FRAC:  0.55-

More Details Click on below link.

Click Here

0

Not only in ABAP any programming language like C, C++, JAVA follows same concept.

     The Floor of 2.31 is 2 
     The Ceiling of 2.31 is 3
     The Floor of 5 is 5 
     The Ceiling of 5 is 5

Not the answer you're looking for? Browse other questions tagged or ask your own question.