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:
- Substituting lt and gt for < and >. As expected, I get unwanted behavior with the floating numbers.
- Doing something like ((0+$rsx) < (0+$sxH)) to try and "remind" perl these are supposed to be numbers. I believe Perl factors this out so it's moot.
I am so close to stamping this bug out and moving on to the next stage of my project. :(
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: When 1000 is less than 1000
by Anonymous Monk on Sep 27, 2010 at 06:31 UTC | |
Re: When 1000 is less than 1000
by AnomalousMonk (Archbishop) on Sep 27, 2010 at 06:45 UTC | |
Re: When 1000 is less than 1000
by sundialsvc4 (Abbot) on Sep 27, 2010 at 14:21 UTC | |
Re: When 1000 is less than 1000
by SavannahLion (Pilgrim) on Sep 28, 2010 at 04:00 UTC | |
Re: When 1000 is less than 1000
by Siddartha (Curate) on Sep 27, 2010 at 07:51 UTC | |
by SavannahLion (Pilgrim) on Sep 28, 2010 at 04:05 UTC |