Q:

Console outputting a certain value - if statement straight after it not working with same value

cout << levelData.interactMap[tileHitX][tileHitY] << endl;
if(levelData.interactMap[tileHitX][tileHitY] == 1.8)
        cout << "pls werk" << endl;

So the cout outputs 1.8...yet the if statement does not work.
It's a function in which I'm passing a struct member to using the & pointer.
It's inside this if statement.
if(levelData.interactMap[tileHitX][tileHitY] >= 1 & levelData.interactMap[tileHitX][tileHitY] <= 1.8)
{
    levelData.interactMap[tileHitX][tileHitY] = levelData.interactMap[tileHitX][tileHitY] + 0.1;
    chop.play();

    cout << levelData.interactMap[tileHitX][tileHitY] << endl;
    if(levelData.interactMap[tileHitX][tileHitY] == 1.8)
        cout << "pls werk" << endl;
}

Calling the function
int action(int facing, sf::Sprite& player, sf::View& view, sf::Clock& actionTimer, levelData& levelData, sf::Sound& chop)

and the define thing for the function
int action(int, sf::Sprite&, sf::View&, sf::Clock&, levelData&, sf::Sound&);

Thanks

A:

As mentioned in several comments, floating point numbers are a little weird when it comes to equality. This is because, to use a reasonable amount of memory, floating point numbers are not stored exactly, but approximated using increasingly small powers of 2 (i.e. 2^-1 + 2^-2 + 2^-4....). As you might expect, this means that there is a margin of error involved, depending on several factors.
As far as your problem is concerned, it comes down to this: don't use "==" on floating point numbers. Instead, check to see if it is within a margin of error with something like:
float acceptableThresholdOfError = .0001;
if(fabs(levelData.interactMap[tileHitX][tileHitY] - 1.8) <= acceptableThresholdOfError)
{ //code }

Obviously, the needed precision determines exactly how small the error threshold should be/can be. This way, even if your variable is not a perfect approximation, it can be thought of as such as long as it's "close enough."    

