ID: 16366 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Closed Bug Type: Math related Operating System: WinXP PHP Version: 4.1.2 New Comment:
why store boolean values in a bigint if someone invented "columns" in SQL? it's a useful thing, you know. but to get your script working, why don't you just binary "&" ? if($data & 2) would check if register two was set. Previous Comments: ------------------------------------------------------------------------ [2002-03-31 12:27:36] [EMAIL PROTECTED] Hmm well the bug of (11>>34) still exists.. anything >>32 or more should be zero. I'm not really doing math, I am just storing boolean values in all the bits of a bigint, and trying to access the high bits has become a problem. I could always divide by 2 34 times but that kinda sucks. I think I will switch to blobs or something. ------------------------------------------------------------------------ [2002-03-31 12:21:09] [EMAIL PROTECTED] and besides, you should consider using more accurate operators for sensitive data: http://www.php.net/manual/en/ref.bc.php PHP is not actually meant to do real-time calculations or to write 3D-engines in. Also, there is no precalculated sine table and no int 13h in PHP :) 11/34 or bcdiv(11, 34) should do the trick. ------------------------------------------------------------------------ [2002-03-31 11:54:25] [EMAIL PROTECTED] AFAIK, PHP stores any number from MySQL as a string, until you access it as a number. If you try to do some math on that number, that will probably not work as expected. Bitshifting won't work either. ------------------------------------------------------------------------ [2002-03-31 11:48:25] [EMAIL PROTECTED] echo (11>>34) produces "2" Also PHP docs state that the max integer is "usually" 32 bits. So what is an unsigned bigint from mysql stored as, and can I use the bit shift operator on it? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16366&edit=1
