Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRC32 - always returns a signed int? 1

Status
Not open for further replies.

SCelia

Programmer
Feb 27, 2002
82
CA
No matter what value I give for crc32() I end up with an integer that could be stored in a signed int column in a mysql database. Is there a way to find out if this would always be the case? Celia
 
I suspect so because I just ran this program and it didn't find any out of range values.

<?

$e = 0;

for($i=0; $i < 1000000; $i++) {

$str = rand(1,999).'.'.rand(1,999).'.'.rand(1,999).'.'.rand(1,999);

if (crc32($str) > 2147483647 || crc32($str) < -2147483648) {
echo &quot;Out of range for an integer $str&quot;;
$e++;
}
}

echo &quot;Done with $e out of range values&quot;;

?> Celia
 
32 bit length is 4 bytes or an int? Celia
 
I had to go look up &quot;RTFM&quot; at the link you put in your sig. I read the manual actually before I even tested the function, but I was idiot enough not to see the 32-bit thing. Thanks for pointing it out. Celia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top