There is a code:
const double Pi = 3.14; double a = Pi; double b = Pi; Type Code:
double x = 3.; double b = (4.0 - x) * Pi; There can be no program, i.e. always assignment var = Pi .
Is it correct in this (and only in this) case to compare a == b ?
Just add. The assignment of a constant in a program might look something like this:
double b = some_expression; if (b < Pi + epsilon && Pi - epsilon < b) b = Pi; And nothing else.
P.S. Ispolzvanie numbers, similar to the mathematical "pi" - for example only, to reality has nothing to do.
Let's try to formulate the question more widely. There are two lines of code coming in a row.
double x = some_value; double y = x; // not double y = some_expression_that_equal_to_x; Types x , y same, this is important. Is the same binary representation of x and y guaranteed?
bwill never be equal toPias a result of any other actions? - Kromster