Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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. :(


In reply to When 1000 is less than 1000 by SavannahLion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-20 13:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found