I’m trying to solve a data mystery here but i’m not sure whether it is my code issue or internet browser issue… it works fine in IE6 and IE8 but somehow the data appears incorrectly when it was used by customers who may not be using IE…
decimal? a = 1.0000m;
decimal? b = 0.6999m;
decimal? c = null;
string aDesc = "";
string bDesc = "";
string cDesc = "";
if (a >= (Decimal).8)
aDesc = "condition A achieved";
if (b >= (Decimal).8)
bDesc = "condition B achieved";
if (c >= (Decimal).8)
cDesc = "condition C achieved";
Does all the strings get assigned at the end of this in all browsers? Thanks.
Note: instead of
(Decimal).8you can use.8m. It’s shorter and a bit cleaner.Comparing a null (as in your Nullable) in this situation results in false in every case. Try this in a fresh project:
If you think about it, it makes sense.
nullmeans an absence of value, which is very different from none (or zero), which are specific values. Comparison against an absence of something has no real definition, it is not larger, nor is is smaller, so both resolve to false. Is a non-existent person taller than me? Nope, he doesn’t exist. Is a non-existent person shorter than me? Nope, he doesn’t exist.EDIT
Also, you’ll find that your second condition (as pointed out by others) is always flat out false.
/EDIT
That’s what you’re seeing, not a browser issue, hope that helps!