c语言存储编码,c语言实型数据的编码和存储(3页)-原创力文档

63) 。 公式 2-2 的几种例外情况: 1、指数编码全部是 1,而尾数编码不全为 0 时,表示±∞; 2、指数编码全为 0 时,表示数 0; 3、指数编码值小于 15(000FH)或尾数编码全为 0 时,表示一 个无效数字。 另外,long double 型数的指数下限为 10-4928,在指数临界时,受 尾数的影响可能会产生其它的无效数字。 由于 20+2-1+…+2-63≈2,所以 long double 型最大数为 2?216383≈ 1.18973?104932。运算最小正数为 8.90823?10-4928。 尾数最小值为 2-63≈1.08420?10-19,long double 型数的有效数字 为 19 位。 3 实型数据的存储 实型数据的存储和整型数据方式相同, 以字节为单位, 逆序存放。 以下以 float 型数据为例说明。 若有 float 型变量 x=106.25,由公式 2-1,可确定 x 的编码为: B1 B2 B3 B4 0 1 0 0 0 0 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 若变量 x 的地址为 194H,则 x 在内存中的存储形式如下: 194H B4 195 H B3 196 H B2 197 H B1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 0 double 型和 long double 型数据的存储形式与 float 型数据的存储 形式类似,不再赘述。

4 结 语 综上所述并结合在 P4 微机上 Turbo C2.0 环境中的实验结果,归 纳出实型数据的相关属性如下表: 数据类型 float double long double 编码 位数 32 64 80 指数 位数 8 11 15 指数取 值范围 -126~127 -1022~1023 -16368~16383 有效 数位 6 15 19 数值范围(近似) ±110-38~±3.40282?1038 ±2.225074?10-308~±1.797693?10308 ±8.90823?10-4928~±1.18973?104932 以上数据主要是通过实验获得, 有些与 float.h 或 values.h 头文件 定义的值相同, 有的则不同, 编码的理论值与实验数据也有一定差异, 不同的 C 编译系统也会有不同的结果,实际应用时,应区别对待。 参考文献 [1] 尹彦芝.C 语言高级实用教程.北京:清华大学出版社,1992 [2] 蒋长景.科学计算和 C 程序集.合肥:中国科学技术大学出版社,1998 [3] 徐金梧等.Turbo C 实用大全.北京:机械工业出版社,1996 [4] 谭浩强.张基温等.C 语言程序设计教程.北京:高等教育出版社,2001 The coding and storage of the real type data in C programming language. Zhou Hengzhong (Department of Computer Science and Technology,

West Anhui University, Lu'an,Anhui, 237012 Abstract: The C programming language has rich data types. It is of great importance to identify data types in program designing, so the intensive research of all types of data is necessary. In Turbo C 2.0, the real-type data includes float, double and long double types with coding length of 4B, 8B and 10B each. From left to right, the first bit is the symbol bit of data and the next is the partial index code with the length of 8b, 11b and 15b each. The remaining part is the mantissa code. The code is stored in reverse order in the unit of byte. The conversion between value and c

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值