本文介绍了是否有任何现实世界的 CPU 不使用 IEEE 754?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在优化数字/统计库的排序函数,基于这样一个假设,即在过滤掉任何 NaN 并稍微处理一下之后,浮点数可以作为 32 位整数进行比较而不改变结果,而双精度数可以被比较为 64 位整数.

I'm optimizing a sorting function for a numerics/statistics library based on the assumption that, after filtering out any NaNs and doing a little bit twiddling, floats can be compared as 32-bit ints without changing the result and doubles can be compared as 64-bit ints.

这似乎将这些数组的排序速度提高了 40%,只要浮点数的位级表示是 IEEE 754,我的假设就成立.人们实际上是否有任何真实世界的 CPU使用(不包括在嵌入式设备中,该库不针对它)使用其他一些可能会打破这个假设的表示?

This seems to speed up sorting these arrays by somewhere on the order of 40%, and my assumption holds as long as the bit-level representation of floating point numbers is IEEE 754. Are there any real-world CPUs that people actually use (excluding in embedded devices, which this library doesn't target) that use some other representation that might break this assumption?

推荐答案

除了有缺陷的奔腾,任何基于 x86 或 x64 的 CPU 都使用 IEEE 754 作为其浮点运算标准.

Other than flawed Pentiums, any x86 or x64-based CPU is using IEEE 754 as their floating-point arithmetic standard.

此处简要概述了 FPA 标准及其采用情况.

Here are a brief overview of the FPA standards and their adoptions.

IEEE 754:       Intel x86, and all RISC systems (IBM Power
                and PowerPC, Compaq/DEC Alpha, HP PA-RISC,
                Motorola 68xxx and 88xxx, SGI (MIPS) R-xxxx,
                Sun SPARC, and others);

VAX:            Compaq/DEC

IBM S/390:      IBM (however, in 1998, IBM added an IEEE 754
                option to S/390)

Cray:           X-MP, Y-MP, C-90; other Cray models have been
                based on Alpha and SPARC processors with
                IEEE-754 arithmetic.

除非您计划在相当奇特的 CPU 架构上支持您的库,否则可以安全地假设目前 99% 的 CPU 符合 IEEE 754.

Unless your planning on supporting your library on fairly exotic CPU architectures, it is safe to assume that for now 99% of CPUs are IEEE 754 compliant.

这篇关于是否有任何现实世界的 CPU 不使用 IEEE 754?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-16 17:14