"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Determine if a C++ Compiler Adheres to the IEEE 754 Standard?

How to Determine if a C++ Compiler Adheres to the IEEE 754 Standard?

Posted on 2025-03-04
Browse:702

How to Determine if a C   Compiler Adheres to the IEEE 754 Standard?

Determining Compiler's Use of IEEE 754 Standard in C

Unlike C, which requires a specific define check to verify if the compiler adheres to the IEEE 754 standard, C offers a more straightforward approach. The C standard includes the numeric_limits class within the std namespace. To determine if the compiler employs IEEE 754, simply access the static member is_iec559 as follows:

std::numeric_limits::is_iec559;

or:

std::numeric_limits::is_iec559;

This expression returns true if IEEE 754 is in use, and false otherwise.

Alternatively, as suggested by Adam's answer, you can also employ another method:

#include 
#include 

int main() {
    double d = -0.0;
    std::cout 

If the compiler supports IEEE 754, this code outputs 0; otherwise, it outputs 1.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3