SAP定点运算(Fixed point arithmetic)

SAP中创建程序时,属性中有一个选项“Fixed point arithmetic”定点运算。英文如下:

Fixed point arithmetic

If you mark this checkbox, all calculations in the program will use fixed point arithmetic.

If you do not, packed numbers (ABAP/4 type P, Dictionary types CURR, DEC or QUAN) will be treated as integers when they are used in assignments, comparisons, and calculations, irrespective of the number of decimal places defined. Intermediate results in arithmetic calculations will also be rounded to the next whole number. The number of decimal places defined is only taken into account when you output the answer using the WRITE statement.

 

仔细读,看懂了点。再看中文翻译

 

定点运算

    如果标记该复选框,该程序中的所有计算都将使用定点运算。

如果未标记,那么当在分配、比较和计算中使用压缩数字,与定义的小数位无关时,就把压缩数字(ABAP/4 类型 P、字典类型 CURRDEC QUAN )作为正数。也将把算法计算中的中间结果取整到下一整数。只有当使用 WRITE 报表输出该答复时,才考虑该小数位数量。

 

懵了吧?我确实懵了。

 

还是看例子吧!

 

    REPORT ZHAOTEST.

    data: zjcd type p decimals 6.
    data: zj type p decimals 5.
    data: cd type p decimals 5.

    zj = '1283.800'.
    cd = '1001'.

    zjcd = zj / cd.

write:/ zjcd.

如果勾选定点运算,结果为:1.282517

如果不勾选,结果为:0.001283

由此可看出,定点计算就是我们常见的那种计算,小数位是定的,小数点在计算过程中是考虑的。

而浮点计算在计算过程中则不考虑小数点。计算过程可理解为zj/cd = 1283800/1001 = 1282.517,转化为zjcd时,需要6位小数,则为1282.517/1000000 = 0.001282517,第七位小数四舍五入,得0.001283

以上纯属猜想,请甄别采纳。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9859323/viewspace-682734/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9859323/viewspace-682734/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值