Quick actions

cmd+k|ctrl+k

Navigation

Languages

Essential C++ / Floating point arithmetic

Snippet info

Language

Cpp

Visibility

public

Author

kkowalczyk

Created

2019-03-27T06:43:52Z

Updated

2019-03-27T06:43:52Z

#include <iostream>
#include <string>

int main(int argc, char **argv) {
    double a = 0.1;
    double b = 0.2;
    double c = 0.3;
    if (a + b == c) {
        // This never prints on IEEE754-compliant machines
        std::cout << "This Computer is Magic!" << std::endl; 
    } else {
        std::cout << "This Computer is pretty normal, all things considered." << std::endl;
    }
}
INFO