ITPUB??ì3
ITPUB论坛 » ERP二次开发 » 关于abap的数据类型


标题: 关于abap的数据类型
离线 zyyatou



精华贴数 0
个人空间 0
技术积分 104 (15988)
社区积分 0 (1431183)
注册日期 2008-5-5
论坛徽章:0
      
      

发表于 2008-6-12 15:05 
关于abap的数据类型

关于数据类型P,举个例子:
data:ff(6) type p  decimals 7 value '121.1133'.
变量的长度是6字节,小数点后是7个字节,对吗?输出的结果是小数点后7位,但总长度就不对了?
还有定义变量长度是以字节为单位?为什么其他类型定义的长度与输出的结果也有冲突?


只看该作者    顶部
离线 leniz
中级会员


精华贴数 0
个人空间 70
技术积分 361 (5320)
社区积分 1 (38779)
注册日期 2005-8-20
论坛徽章:0
      
      

发表于 2008-6-14 10:32 
SAP ABAP:
P
The valid length for packed numbers is between 1 and 16 bytes; two decimal places are packed into one byte, whereby the last byte only contains one place and the plus/minus sign; after the decimal separator, up to 14 decimal places are permitted. Depending on the field length len and the number of decimal places dec, the following applies for the value area: (-10^(2len -1) +1) / (10^(+dec)) to (+10^(2len -1) -1) /(10^(+dec)) in steps of 10^(-dec). Values in between this range are rounded off.

所以6表示的应该小数点前后各6,故是 6 * 2 ,但是要扣除一个字符位 ,所以为  (-10^(2len -1) +1) / (10^(+dec))  = -10000
到 (+10^(2len -1) -1) /(10^(+dec))  = 10000
所以值得范围应该是 1000  到 -1000 ,小数位你写再多,最后也是只留7位的。


只看该作者    顶部
离线 xiaomifan001



精华贴数 0
个人空间 0
技术积分 10 (93212)
社区积分 127 (2960)
注册日期 2008-2-14
论坛徽章:0
      
      

发表于 2008-6-18 14:04 
回复 #2 leniz 的帖子

朋友写的好。加我(frank.dl@live.cn


只看该作者    顶部
 
    

相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问