in reply to Re: comparison of packed signed integers
in thread comparison of packed signed integers

Hi BrowserUK and thank you for your fast answer :-)

Here is my code for the file creation.

open(OUT,'>'.$fil) or die $!; binmode OUT; for $i(1 .. 10000){ $lat=int(rand(20000))+440000; $lon=int(rand(10000))+20000; $typ=chr(31); $cod=pack('l>l>C',$lat,$lon,$typ); print OUT $cod; } close(OUT);
And here is my code for the read and comparison:

$lah=pack('l>',$lah); $lab=pack('l>',$lab); $loh=pack('l>',$loh); $lob=pack('l>',$lob); open(IN,"<ch"; @fil=stat(IN); $num=$fil[7]/9; binmode(IN); for(1 .. $num){ read(IN,$lat,4); read(IN,$lon,4); read(IN,$pyt,1); if(($lat lt $lah) && ($lat gt $lab) && ($lon lt $loh) && ($lon gt $lo +b)){ print "OK"; } }

But it is never OK :-(

Replies are listed 'Best First'.
Re^3: comparison of packed signed integers
by BrowserUk (Patriarch) on Oct 30, 2011 at 12:16 UTC

    Where are the values of $lah, $lab, $loh, $lob set?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      They are set just above the given code and they compare correctly if I don't pack them and if I unpack the values in the file too !
        Now it works properly (the new version of the program was improperly uploaded on my server, sorry), many thanks to all of you for your gentle support and have a nice end of week !
        They are set just above the given code

        That's not very useful information. Obviously, it was their value that I was interested in.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.