正在加载图片...
while Loop pitfall -2 float count =0. 0f while( count ! 1 0f ) count count +0.3333333f //seven 3s Using Real Numbers Loop 2 terminates, but Loop 1 does not because only an approximation of a real 2) float count =0.0f number can be stored in a computer memory while( count ! 1 0f ) count count +0.33333333f //eight 3s C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 7-9© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 7 - 9 while Loop Pitfall - 2 Using Real Numbers Loop 2 terminates, but Loop 1 does not because only an approximation of a real number can be stored in a computer memory. float count = 0.0f; while ( count != 1.0f ) { count = count + 0.33333333f; } //eight 3s 2 float count = 0.0f; while ( count != 1.0f ) { count = count + 0.3333333f; } //seven 3s 1
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有