#include <iostream>
int main()
{
double number1 = 1.4999999999999999;
double number2 = 1.499999999999999;
std::cout << "NUMBER 1 => ROUND (" << number1 << ") = " << round(number1) << std::endl;
std::cout << "NUMBER 2 => ROUND (" << number2 << ") = " << round(number2) << std::endl;
std::cin.get();
}
Output for above code is as follows: -
NUMBER 1 => ROUND (1.5) = 2
NUMBER 2 => ROUND (1.5) = 1
I am unclear how my number1 and number2 are changing to 1.5 and if so they're changing to 1.5 then why two different output's of round function for same number.
Tried using long double still same output
I am using Visual Studio 2019, will that make any difference?