-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDivideByZero.cpp
42 lines (31 loc) · 935 Bytes
/
DivideByZero.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* \file DivideByZero.cpp
* \brief
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//--------------------------------------------------------------------------------------------------
int main(int, char **)
{
const double a = 1.0 / 0.0; // inf
std::cout << STD_TRACE_VAR(a) << std::endl;
const double b = -1.0 / 0.0; // -inf
std::cout << STD_TRACE_VAR(b) << std::endl;
const double c = 0.0 / 0.0; // -nan
std::cout << STD_TRACE_VAR(c) << std::endl;
const double d1 = 10.0 / 0.0; // inf
std::cout << STD_TRACE_VAR(d1) << std::endl;
#if 0
const double d2 = 10.0 / 0; // error: division by zero [-Werror=div-by-zero]
std::cout << STD_TRACE_VAR(d2) << std::endl;
#endif
return EXIT_SUCCESS;
}
//--------------------------------------------------------------------------------------------------
#if OUTPUT
a: inf
b: -inf
c: -nan
d1: inf
#endif