Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do any real-world CPUs not use IEEE 754?

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.

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?


  • https://en.wikipedia.org/wiki/Single-precision_floating-point_format
    (binary32, aka float in systems that use IEEE754)
  • https://en.wikipedia.org/wiki/Double-precision_floating-point_format
    (binary64, aka double in systems that use IEEE754)
like image 613
dsimcha Avatar asked Feb 10 '10 04:02

dsimcha


People also ask

Is IEEE 754 still used?

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.

What languages use IEEE 754?

Most languages use IEEE754 doubles as their basic data type for rational numbers (C and C++ via double , Python via float ). In addition to representing floating point values, IEEE 754 also allows representation of two other numeric data types.

Why is IEEE 754 the standard?

IEEE developed the IEEE 754 floating-point standard. This standard defines set formats and operation modes. All computers conforming to this standard would always calculate the same result for the same computation. This standard does not specify arithmetic procedures and hardware to be used to perform computations.

How precise is IEEE 754?

The IEEE 754 standard specifies a binary32 as having: Sign bit: 1 bit. Exponent width: 8 bits. Significand precision: 24 bits (23 explicitly stored)


1 Answers

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

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. 

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.

like image 90
Andrew Moore Avatar answered Sep 19 '22 21:09

Andrew Moore