# Why does (5/3) not equal (5/3)?

#### micha_eleric

Code:
``````int highest = 5;
int lowest = 3;
std::cout << "((float)highest/(float)lowest) = " << ((float)highest/(float)lowest) << "\n";
std::cout << "(5.0/3.0) = " << (5.0/3.0) << "\n";
std::cout << "(((float)highest/(float)lowest) == (5.0/3.0)) = "
<< (((float)highest/(float)lowest) == (5.0/3.0)) << "\n";``````

output:

Code:
``````((float)highest/(float)lowest) = 1.66667
(5.0/3.0) = 1.66667
(((float)highest/(float)lowest) == (5.0/3.0)) = 0``````

why does (5/3) not equal (5/3)?

#### rtschaefer99

Code:
``````int highest = 5;
int lowest = 3;
std::cout << "((float)highest/(float)lowest) = " << ((float)highest/(float)lowest) << "\n";
std::cout << "(5.0/3.0) = " << (5.0/3.0) << "\n";
std::cout << "(((float)highest/(float)lowest) == (5.0/3.0)) = "
<< (((float)highest/(float)lowest) == (5.0/3.0)) << "\n";``````

output:

Code:
``````((float)highest/(float)lowest) = 1.66667
(5.0/3.0) = 1.66667
(((float)highest/(float)lowest) == (5.0/3.0)) = 0``````

why does (5/3) not equal (5/3)?
Round off error; (5.0/3.0) is a double, not a float

• micha_eleric