如果我们回想一下我们一开始讲过的数据对象的种类,浮点数,整数,字符串,它们实际上有相同的行为方式。
If we go back up to the kinds of data objects we started with, floats, ints, strings, they actually behave the same way.
浮点数和双精度数字的二进制表示。
为什么需要用单独的宏进行浮点数比较?
Why do you need separate macros for floating point comparisons?
还可以使用指数表示浮点数,参见清单8。
Floats can also be expressed using exponents, as shown Listing 8.
简单类型包括字符串、浮点数、整数、枚举等。
Simple types include string, float, integer, enumeration, etc.
浮点数并不是实数。
坐标值是数字(小数、浮点数等),不是字符串。
The coordinate values are numeric (decimal, float, etc.), not character strings.
随着数字变大,它们之间的浮点数就会越来越少。
所以我可以通过改变其中一个,整型数为浮点数。
And I can fix this just by changing one of those values to a floating point.
浮点数不是精确值,所以使用它们会导致舍入误差。
Floating point Numbers are not exact, and manipulating them will result in rounding errors.
我想确保这儿我得到的是一个浮点数,我该怎么做呢?
I can't rely on the user. I want to make sure I get a float in it, so how do I do that?
正如你希望的我要试着把他们转化为浮点数,等一等。
And as you might expect, I'm going to then try and see if I can convert that into a float.
Google提供清单9所示的宏以支持浮点数比较。
Google provides the macros shown in Listing 9 for floating point comparisons.
对于浮点数,您将在整数部分和小数部分之间放置小数点。
For floating-point Numbers, you place a decimal as the separator between the whole part of the number and the fraction.
NaN的无序性质使得在比较浮点数时更容易发生错误。
The non-ordered nature of NaN adds further opportunities for error when comparing floating point numbers.
当然,这并不总是可能的,但您应该意识到要限制浮点数比较。
This is, of course, not always possible, but you should be aware of the limitations of floating point comparison.
IEEE 754用科学记数法以底数为2的小数来表示浮点数。
IEEE 754 represents floating point Numbers as base 2 decimal Numbers in scientific notation.
区别在于一个事实:计算机中使用的浮点数据类型无法包含每个实数。
The difference lies in the fact that floating-point data types used in computers can't hold every real number.
由有限精度浮点数字引起的很小的舍入错误就会严重歪曲数学精度计算。
Mathematically precise calculations can be thrown severely askew by small round-off errors caused by finite-precision floating-point Numbers.
浮点数最好用来表示象测量值这类数值,这类值从一开始就不怎么精确。
Floating point Numbers are best reserved for values such as measurements, whose values are fundamentally inexact to begin with.
DECIMAL数据类型需要的存储空间通常要比浮点数据类型大得多。
The storage required for a DECIMAL data type is potentially much larger than it is for a normal floating-point data type.
您也可以使用其它的范围的数,但是我的经验告诉我,浮点数是最有效的。
Other ranges can be used, but in my experience floating point numbers work best.
程序期望查找ascii格式的单精度浮点数;任何无关的字符都将忽略。
The program expects to find a single floating-point number in ASCII format; any extraneous characters will be ignored.
在第2部分,我将探讨专为操作浮点数(与抽象实数相反)而设计的函数。
In Part 2, I'll explore the functions more designed for operating on floating point Numbers as opposed to abstract real Numbers.
如果我想要得到真正的除法答案,我需要把他们之中的一个,变为浮点数类型。
If I wanted to get full, real division, I should make one of them a float.
当然,结果不一定是有意义的 —— 比如字符串和浮点数的比较就没有意义。
Sure, the result would not necessarily be meaningful -- a string is neither objectively less than nor greater than a float.
但请注意,这个有效负载看起来非常奇怪,不象是只返回一个浮点数的有效负载。
However, note that the payload looks very strange for a payload that simply returns a floating point number.
HTTP内容协商使用短浮点数来表示各种可协商参数的相对重要性(或权重)。
HTTP content negotiation uses short floating point numbers to indicate the relative importance, or weight, of various negotiable parameters.
如果参数为0,则对应的浮点数和双精度数的结果分别是- 127和- 1023。
If the argument is zero, then the result will be -127 for a float and -1023 for a double.
如果参数为0,则对应的浮点数和双精度数的结果分别是- 127和- 1023。
If the argument is zero, then the result will be -127 for a float and -1023 for a double.
应用推荐