Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

over 6 years ago

Language

C++

Compiler

gcc HEAD 9.0.0 20181008 (experimental)

Options
Warnings
Boost 1.68.0
C++2a(GNU)
no pedantic
Raw compiler options
-Wall -Wextra -Wfloat-equal

Author

anonymous

over 6 years ago

$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.68.0/gcc-head/include -std=gnu++2a -Wall -Wextra -Wfloat-equal
prog.cc: In function 'int main()':
prog.cc:7:77: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
7 |     cout << (0.68 + 0.04) << " == " << 0.72 << ": " << (0.72 == (0.68 + 0.04)) << endl;
  |                                                                             ^
prog.cc:8:77: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
8 |     cout << (0.69 + 0.04) << " == " << 0.73 << ": " << (0.73 == (0.69 + 0.04)) << endl;
  |                                                                             ^
0.72 == 0.72: 0
0.73 == 0.73: 1
Exit Code:
0