二进位也可以很有趣—交通大学.ppt

  1. 1、本文档共146页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
二进位也可以很有趣—交通大学

Object Oriented Concept 蔡文能 交通大學資訊工程學系 tsaiwn@.tw Agenda Review: Data Representation in the computer Why using struct? What is Object? What is class? OO Concept? Why using class? How to build a component? OO features Encapsulation, Information Hiding, Inheritance, Polymorphism 電腦內如何儲存資料? 如何表示文字? ASCII? EBCDIC? … 如何表示數值? 整數? (char, short, int, long) long long, boolean ? 實數? (float, double) 數值的範圍? 實數數值的準確度(precision) 其它? 問題與思考 (如何表示文字? ) #includestdio.h unsigned char x[999] = { 0 }; main( ) { int m = 0x41, n=97; x[0] = m; x[1]=n; x[2] = 98; x[3]=99; x[7] = 063; x[8]=0x38; /* 063 ==51 */ x[4] = Y; x[5]= o; x[6]= u; printf(==%s==\n, x); } 問題與思考 (中文碼?) #includestdio.h unsigned char x[9] = { 0 }; main( ) { int m = 0xa4, n=0x6a; x[0] = m; x[1]=n; x[2] = 0xae, x[3]=97; x[4] = 0xa6, x[5]=0x6e; printf(==%s==\n, x); } 實數與準確度(precision) #includestdio.h float x, xdelta; int i; /*precision.c */ main( ) { double y; x = 1234567.2, xdelta = 0.0001; printf(Before loop, x=%f\n, x); for(i=1; i= 8000; i++){ y = x + xdelta; /******/ if(i == 1) printf(first y = %f\n, y); x = y; } printf(After loop, x=%f\n, x); } float 實數準確度七位多 ccbsd2:precision/ gcc precision.c ccbsd2:precision/ ./a.out Before loop, x=1234567.250000 first y = 1234567.250100 After loop, x=1234567.250000 ccbsd2:precision/ float 實數佔用 32 bits double 實數準確度 #includestdio.h double x, xdelta; int i; /*precdbl.c */ main( ) { double y; x = 1234567.2, xdelta = 0.0001; printf(Before loop, x=%f\n, x); for(i=1; i= 8000; i++){ y = x + xdelta; /******/ if(i == 1) printf(first y = %f\n, y); x = y; } printf(After loop, x=%f\n, x); } double 實數準確度十五位多 ccbsd2:precision/ gcc precdbl.c ccbsd2:precision/ ./a.out Before loop, x=1234567.200000 first y = 1234567.200100 After loop, x=1234568.000001 ccbsd2:precision/

文档评论(0)

wuyoujun92 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档