Filling in the gaps—floating-point numbers
2015-11-28 23:05
459 查看
浮点常量也可以表示成科学或指数计数法。例如,下面的2句变量声明会初始化为相同的值:
float a = 0.0001;
float b = 1e-4;
The e can be thought of as representing “times 10 to the power of.”
On the iPhone,as with most modern platforms,floating-point values are stored in a format called the IEEE 754 standard.
With only a restricted set of values you can use for the mantissa , you can’t represent every value in the
extended range enabled by the exponent.This leads to the interesting discovery that certain decimal values
can't be stored precisely.举个例子,下面代码片段的输出,可能会让你感到惊讶:
float f = 0.6f;
NSLog(@"0.6 = %0.10f", f);
The %0.10f bit in the call to NSLog requests that the value be printed to 10 decimal places,
but instead of the value 0.6000000000,the value 0.6000000238 gets printed
相关文章推荐
- Float and the form of expression of floating-point number in memory
- 格式化硬盘时报错: dev is apparently in use by the system; will not make a filesystem here
- XML错误信息Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.xsd). For more information, right click on the message in the Problems View ...
- Just do nothing, smile in the dream and waiting for the sun raising.
- 2388 Who's in the Middle(简单排序)
- poj 2388 Who's in the Middle
- ubuntu 将一般的用户加入sudo组 is not in the sudoers file
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
- Git提交时提示‘The file will have its original line endings in your working directory’
- Error:The number of method references in a .dex file cannot exceed 64K 问题解决
- net.sf.json.JSONException: There is a cycle in the hierarchy!错误解决方案
- (NOT CLEAR)Question 45: Which of the following options are returned by the typeid operator in C++?
- 解决Unable to locate theme engine in module_path: "pixmap"
- Changing the Auto-Logout Timeout in SSH
- HDOJ 1157 Who's in the Middle(水)
- XXX could not be redeployed because it could not be completely removed in the undeployment phase. th
- org.apache.axis2.AxisFault: The ServiceClass object does not implement the required method in the following form: OMElement get
- mpociot/laravel-apidoc-generator There are no commands defined in the "api" namespace.
- Windows Integrated Authentication in the combination of IIS and Tomcat
- 投票程序2 图像识别 Using The Office 2007 OCR Component in C#