简体   繁体   English

abap中天花板和地板function的区别?

[英]Difference between ceil and floor function in abap?

I'm newbie to abap, please let me know,the use of ceil and floor function in abap.我是abap的新手,请告诉我,在abap中使用ceil和floor function。

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.为了补充 Hyperboreus 的答案,严格来说,这不是 ABAP 问题,因为天花板和地板函数也是其他语言中包含的通用数学函数。

You can try it for yourself with the following ABAP code to get a hands-on understanding:您可以使用以下 ABAP 代码亲自尝试,以获得动手理解:

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.

Unfortunatly I do not know a thing about abap, but ceil and floot are generally defined as follows:可惜我对abap一无所知,但是ceil和floot一般定义如下:

The floor of a float value is the next lowest integer.浮点值的下限是次低的 integer。

The ceiling of a float value is the next highest integer.浮点值的上限是次高的 integer。

Exempli gratia:示例:

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

FLOOR returns the nearest Smallest integer FLOOR返回最近的最小integer
CEIL returns the nearest Largest Interger CEIL返回最近的最大整数

CEIL has the meaning of rounding the number up - to the ceiling... CEIL 的意思是将数字向上舍入 - 到天花板...
FLOOR has the meaning of rounding the number down - to floowr... FLOOR 的意思是将数字向下舍入 - 使...

as previously answered:如前所述:
eg.例如。 value 4.1 will be:值 4.1 将是:

floor -> 4.0地板-> 4.0
ceil -> 5.0细胞 -> 5.0

ceil is return Smallest integer value. ceil 是返回最小的 integer 值。

floor is return Largest integer value. floor 是返回最大的 integer 值。

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 点击这里

Not only in ABAP any programming language like C, C++, JAVA follows same concept.不仅在 ABAP 中,任何编程语言(如 C、C++、JAVA)都遵循相同的概念。

     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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM