Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: When 1000 is less than 1000

by SavannahLion (Pilgrim)
on Sep 28, 2010 at 04:00 UTC ( [id://862349] : note . print w/replies, xml ) Need Help??


in reply to When 1000 is less than 1000

After reading the responses and dealing with a little downtime at work, I went through the code and finally pinpointed the problematic assignment at:

#The assignments are condensed test values for the following formula. my ($sx1, $sy1, $sm, $rx1, $ry1, $rm) = (1000, 1000, 1.5574077246549, +1000, 1000, 0.871447982724319); my $rsx = ($sy1 - $ry1 + $rm * $rx1 - $sm * $sx1) / ($rm - $sm);

Even though the values plugged into the formula come out to 1000, I guess that isn't the case with the floating numbers. Since I didn't want to bang my head on this forever I figured I can somewhat predict what numbers will be dumped out by the formula. My kludge is to compare the four known values with each other then jump the entire block of problematic code if they equal each other.

I can't believe this never occurred to me. I rarely mix whole integers with floats and this is the first time I've done any comparisons. In retrospect, this is something I should have remembered from my first year in course work. Such as never using a float value to control a loop. Should have puzzled this out on my own with the realization I was comparing a float to an integer.

Oh well, I'm not happy about the kludge, but I can live with it.