|No such thing as a small change|
When 1000 is less than 1000by SavannahLion (Pilgrim)
|on Sep 27, 2010 at 05:48 UTC||Need Help??|
SavannahLion has asked for the wisdom of the Perl Monks concerning the following question:
I honestly have no idea what's causing this. I can't even replicate the bug in a separate test.
In a nut shell, I am doing a set of comparisons between values in this manner (actual snippet): return ('','') if ($rsx < $sxL); where $rsx and $syH are both numbers (generally floats). In a strange bug, whenever either scalar sports the value of 1000, then the comparison above results in a TRUE!
The scalars hold values that are pretty much abused and beaten. Sometimes, I'll introduce values into the formula (this is where I get the value 1000 from), usually done if a formula can't be solved (eg divide by zero or if I want the value to specifically come out to 1000, even if the result would've been something different). In other words, if I reach that point where I'm comparing the two scalars, I know that I will sometimes be comparing two values of 1000 and I expect it not to return TRUE.
Yet, it appears to return TRUE nearly every time I end up checking if 1000 < 1000
I am truly baffled by this. Have I completely misunderstood the usage between <, > and their counterparts lt and gt? Is there some behavior difference between integers and floating numbers? Is perl misinterpreting my intent that these are indeed numbers and are treating my scalars as strings?
Some of the things I've tried:
I am so close to stamping this bug out and moving on to the next stage of my project. :(