如果我们回想一下我们一开始讲过的数据对象的种类,浮点数,整数,字符串,它们实际上有相同的行为方式。
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.
随着数字变大,它们之间的浮点数就会越来越少。
浮点数不是精确值,所以使用它们会导致舍入误差。
Floating point Numbers are not exact, and manipulating them will result in rounding errors.
对于浮点数,您将在整数部分和小数部分之间放置小数点。
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.
Google提供清单9所示的宏以支持浮点数比较。
Google provides the macros shown in Listing 9 for floating point comparisons.
IEEE 754用科学记数法以底数为2的小数来表示浮点数。
IEEE 754 represents floating point Numbers as base 2 decimal Numbers in scientific notation.
否则,如果其中一个参数是浮点数,另一个也要转换成浮点数。
Otherwise, if either argument is a floating point number, the other is converted to floating point.
区别在于一个事实:计算机中使用的浮点数据类型无法包含每个实数。
The difference lies in the fact that floating-point data types used in computers can't hold every real number.
浮点数最好用来表示象测量值这类数值,这类值从一开始就不怎么精确。
Floating point Numbers are best reserved for values such as measurements, whose values are fundamentally inexact to begin with.
在第2部分,我将探讨专为操作浮点数(与抽象实数相反)而设计的函数。
In Part 2, I'll explore the functions more designed for operating on floating point Numbers as opposed to abstract real Numbers.
DECIMAL数据类型需要的存储空间通常要比浮点数据类型大得多。
The storage required for a DECIMAL data type is potentially much larger than it is for a normal floating-point data type.
CPhase的第一个参数是(经典的)浮点数,第二个参数是一个量子位。
CPhase takes a (classical) floating point number as its first argument and a qubit as it's second argument.
许多设计用来读取浮点数的例程可能会允许“NaN”(非数字)这样的值。
Many routines designed to read floats may allow values such as "NaN" (not a number).
如果我想要得到真正的除法答案,我需要把他们之中的一个,变为浮点数类型。
If I wanted to get full, real division, I should make one of them a float.
HTTP内容协商使用短浮点数来表示各种可协商参数的相对重要性(或权重)。
HTTP content negotiation uses short floating point numbers to indicate the relative importance, or weight, of various negotiable parameters.
当然,结果不一定是有意义的 —— 比如字符串和浮点数的比较就没有意义。
Sure, the result would not necessarily be meaningful -- a string is neither objectively less than nor greater than a float.
Regan推测这个特殊数字的麻烦之处在于它是“最大的次法线双精度浮点数”。
Regan speculated that this particular number is troublesome because it is the "largest subnormal double-precision floating-point number."
在第2部分中,我主要关注这样一些函数,它们的目的是操作浮点数,而不是抽象实数。
Here in Part 2, I focus on the functions that make sense only when you realize that they're designed for operating on floating-point Numbers instead of abstract real Numbers.
像C语言一样,Go提供了一系列的基本类型,常见的布尔,整数和浮点数类型都具备。
Like C, Go offers a handful of primitive types. The usual Boolean, integer and floating-point types are available.
longdoubleIEEE双字节扩展浮点数15位指数,64位带符号小数。
Long double IEEE double extended floating point exponent of 15 bits and signed fraction of 64 bits.
不过,随后则需要考虑正常数字中多出的1位,然后再转换回范围在1到2之间的浮点数。
However, you then need to account for the extra 1-bit in a normalized number, and then convert back to a floating-point number between 1 and 2.
如果参数为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.
应用推荐