How can "maxBuildings < sh.currentBuildings" and "sh.currentBuildings >= maxBuildings" have different value?

My code is
declarations

    public int maxBuildings;
    public int currentBuildings;
        sh.currentBuildings = 0;
        sh.maxBuildings = 2;
        Debug.Log($"Test A {sh.currentBuildings == 0} >= {sh.maxBuildings==2}" +
                  $"::{maxBuildings < sh.currentBuildings }::{sh.currentBuildings >= maxBuildings} ::{2<0}::{0>=2}");
        int x = 0;
        int y= 2;
       Debug.Log($"test B {x == 0} >= {y==2}" +
                  $"::{y< x }::{x >= y} ::{2<0}::{0>=2}");

and the log is

Test A True >= True::False::True ::False::False
test B True >= True::False::False ::False::False

I do not understand how test A and Test B logs can differ in the evaluation of the >= comparison.
There is no getter or setter just plain ints

Am I missing something or is this a compiler bug?
I rebooted my machine and have been changing the code to test it so the code should have recompiled.

You seem to be comparing against two different values. sh.maxBuildings and just maxBuildings.

Thank you. :face_with_spiral_eyes: Time to for me to stop coding today.

1 Like