On Tuesday 17 May 2011 22:06:34 David Harkness wrote:
It appears that PHP is truncating the constant 0x8000 to be within
MIN_INT and MAX_INT instead of as a bit field, but when shifting 1 31 it
doesn't do apply any constraints. That's pretty typical of
bit-manipulation: it will merrily
Hello, all!
I've encountered odd behavior of PHP regarding bitwise AND operation when
dealing with 31-st bit, and kindly ask to give me some pointers.
Consider the following snippet:
$tst1 = (1 31);
$tst2 = 0x8000;
$tst1_eq = $tst1 0x8000;
$tst2_eq = $tst2 0x8000;
print
Hi,
Hmm.. interesting...
tst1=-2147483648, tst1_eq=-2147483648, tst1_type=integer tst2=2147483648,
tst2_eq=-2147483648, tst2_type=double at me...
PHP Version 5.3.3-1ubuntu9.5 (Apache 2.0 - i686)
Valentine
On Tue, May 17, 2011 at 5:19 PM, Vitalii Demianets
vi...@nppfactor.kiev.uawrote:
Hello,
On Tuesday 17 May 2011 18:31:00 Bálint Horváth wrote:
Hi,
Hmm.. interesting...
tst1=-2147483648, tst1_eq=-2147483648, tst1_type=integer tst2=2147483648,
tst2_eq=-2147483648, tst2_type=double at me...
PHP Version 5.3.3-1ubuntu9.5 (Apache 2.0 - i686)
That is what I expected too.
There are 2
It appears that PHP is truncating the constant 0x8000 to be within
MIN_INT and MAX_INT instead of as a bit field, but when shifting 1 31 it
doesn't do apply any constraints. That's pretty typical of bit-manipulation:
it will merrily slide 1 bits off either end. This explains why produces 0
On 24 August 2010 21:42, Andy McKenzie amckenz...@gmail.com wrote:
On Tue, Aug 24, 2010 at 3:55 PM, Ford, Mike m.f...@leedsmet.ac.uk wrote:
-Original Message-
From: Andy McKenzie [mailto:amckenz...@gmail.com]
Sent: 24 August 2010 17:24
To: php-general@lists.php.net
Subject: Re: [PHP
Please stop arguing this pointless topic on the php mailing list.
Regards
Peter
--
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype
--
PHP General Mailing List (http://www.php.net/)
From: Richard Quadling
On 24 August 2010 21:42, Andy McKenzie amckenz...@gmail.com wrote:
On Tue, Aug 24, 2010 at 3:55 PM, Ford, Mike m.f...@leedsmet.ac.uk wrote:
From: Andy McKenzie [mailto:amckenz...@gmail.com]
From your example, this would have shown me what I needed to know:
Then taking
On 20 August 2010 17:00, Andy McKenzie amckenz...@gmail.com wrote:
Thanks to everyone who responded. I've dealt with binary math
before, but it never occurred to me (and doesn't seem to be anywhere
in the document page at php.net!) that it would automatically pad the
number I entered.
There
On Tue, Aug 24, 2010 at 11:06 AM, Richard Quadling rquadl...@gmail.com wrote:
On 20 August 2010 17:00, Andy McKenzie amckenz...@gmail.com wrote:
Thanks to everyone who responded. I've dealt with binary math
before, but it never occurred to me (and doesn't seem to be anywhere
in the document
On Tue, 2010-08-24 at 12:24 -0400, Andy McKenzie wrote:
On Tue, Aug 24, 2010 at 11:06 AM, Richard Quadling rquadl...@gmail.com
wrote:
On 20 August 2010 17:00, Andy McKenzie amckenz...@gmail.com wrote:
Thanks to everyone who responded. I've dealt with binary math
before, but it never
-Original Message-
From: Andy McKenzie [mailto:amckenz...@gmail.com]
Sent: 24 August 2010 17:24
To: php-general@lists.php.net
Subject: Re: [PHP] Bitwise NOT operator?
From your example, this would have shown me what I needed to know:
Then taking the value of E_NOTICE...
1000
On Tue, Aug 24, 2010 at 3:55 PM, Ford, Mike m.f...@leedsmet.ac.uk wrote:
-Original Message-
From: Andy McKenzie [mailto:amckenz...@gmail.com]
Sent: 24 August 2010 17:24
To: php-general@lists.php.net
Subject: Re: [PHP] Bitwise NOT operator?
From your example, this would have shown
Hey everyone,
I'm really not sure what's going on here: basically, the bitwise
NOT operator seems to simply not work. Here's an example of what I
see.
Script
$ cat bintest2.php
?php
$bin = 2;
$notbin = ~$bin;
echo Bin: . decbin($bin) . !bin: . decbin($notbin)
On 20 August 2010 17:10, Andy McKenzie amckenz...@gmail.com wrote:
Hey everyone,
I'm really not sure what's going on here: basically, the bitwise
NOT operator seems to simply not work. Here's an example of what I
see.
Script
$ cat bintest2.php
?php
$bin = 2;
On 20 August 2010 17:41, Peter Lind peter.e.l...@gmail.com wrote:
On 20 August 2010 17:10, Andy McKenzie amckenz...@gmail.com wrote:
Hey everyone,
I'm really not sure what's going on here: basically, the bitwise
NOT operator seems to simply not work. Here's an example of what I
see.
Thanks to everyone who responded. I've dealt with binary math
before, but it never occurred to me (and doesn't seem to be anywhere
in the document page at php.net!) that it would automatically pad the
number I entered.
The example I gave was essentially a test I was running: in the
real
-- Forwarded message --
From: sean greenslade [EMAIL PROTECTED]
Date: Fri, Oct 31, 2008 at 11:22 PM
Subject: Re: [PHP] Bitwise operation giving wrong results
To: Yeti [EMAIL PROTECTED]
Cool, thanks. It worked. I didn't know you typeset PHP like that.
On Thu, Oct 30, 2008 at 3
Usually in PHP one does not take much care about the data types, but
in this case you absoloodle have to.
If you use bit operators on a character then its ascii number will be
taken instead (how should a number based operation work with a
string?)
also if you pass on $_GET params directly into ay
I have the following code as a test:
?php
$a = $_GET['a'];
$b = $_GET['b'];
echo $a .. $b . = ;
$out = $a $b;
echo $out;
//echo 15 2;
?
if I set a to 15 and b to 2 in the URL like so:
test.php?a=15b=2
it outputs zero as the answer. When I run the hard-coded '' operation (the
commented
On Wed, 2008-10-29 at 20:01 -0400, sean greenslade wrote:
I have the following code as a test:
?php
$a = $_GET['a'];
$b = $_GET['b'];
echo $a .. $b . = ;
$out = $a $b;
echo $out;
//echo 15 2;
?
if I set a to 15 and b to 2 in the URL like so:
test.php?a=15b=2
it outputs
Ashley Sheridan wrote:
On Wed, 2008-10-29 at 20:01 -0400, sean greenslade wrote:
I have the following code as a test:
?php
$a = $_GET['a'];
$b = $_GET['b'];
echo $a .. $b . = ;
$out = $a $b;
echo $out;
//echo 15 2;
?
if I set a to 15 and b to 2 in the URL like so:
test.php?a=15b=2
it
On Tue, July 4, 2006 7:35 am, Mathijs wrote:
//Do if VALIDATE_CHECK1 is set BUT NOT when VALIDATE_CHECK3 is set.
if ($flag2 self::VALIDATE_CHECK1 $flag2 ~self::VALIDATE_CHECK3)
Did you check operator precedence for versus ?
Perhaps you just need parentheses...
I'm also not at all sure the
Hello there.
I am working with some bitwise Operators for validating some variables.
Now i need to know if an certain bit is NOT set and an other bit IS set.
Example.
?php
const VALIDATE_CHECK1 = 1;
const VALIDATE_CHECK2 = 2;
const VALIDATE_CHECK3 = 4;
const VALIDATE_ALL= 7;
//--Example
Mathijs wrote:
Hello there.
I am working with some bitwise Operators for validating some variables.
Now i need to know if an certain bit is NOT set and an other bit IS set.
Example.
?php
const VALIDATE_CHECK1 = 1;
const VALIDATE_CHECK2 = 2;
const VALIDATE_CHECK3 = 4;
const
Jochem Maas wrote:
Mathijs wrote:
Hello there.
I am working with some bitwise Operators for validating some variables.
Now i need to know if an certain bit is NOT set and an other bit IS set.
Example.
?php
const VALIDATE_CHECK1 = 1;
const VALIDATE_CHECK2 = 2;
const VALIDATE_CHECK3 = 4;
Mathijs wrote:
Jochem Maas wrote:
Mathijs wrote:
...
Thank you very much.
This seems to work :).
cool. heres's a couple of funcs that might help you to understand bitwise
operations better:
?php
/* whether there is only 1 single bit set or not */
function single_bit_set(/*int*/ $i)
Jochem Maas wrote:
Mathijs wrote:
Jochem Maas wrote:
Mathijs wrote:
...
Thank you very much.
This seems to work :).
cool. heres's a couple of funcs that might help you to understand bitwise
operations better:
?php
/* whether there is only 1 single bit set or not */
function
Jochem Maas wrote:
Mathijs wrote:
Jochem Maas wrote:
Mathijs wrote:
...
Thank you very much.
This seems to work :).
cool. heres's a couple of funcs that might help you to understand bitwise
operations better:
?php
/* whether there is only 1 single bit set or not */
function
Jochem Maas wrote:
Mathijs wrote:
Jochem Maas wrote:
Mathijs wrote:
...
Thank you very much.
This seems to work :).
cool. heres's a couple of funcs that might help you to understand bitwise
operations better:
?php
/* whether there is only 1 single bit set or not */
function
Jochem Maas wrote:
Mathijs wrote:
Jochem Maas wrote:
Mathijs wrote:
...
Thank you very much.
This seems to work :).
cool. heres's a couple of funcs that might help you to understand bitwise
operations better:
?php
/* whether there is only 1 single bit set or not */
function
Hello,
From php manual:
$a $b Shift leftShift the bits of $a $b steps to the left (each step
means multiply by two)
$a $b Shift rightShift the bits of $a $b steps to the right (each step
means divide by two)
So i ask what this output?
$a = 4;
$b = 3;
echo $a $b;
echo $a $b;
Angelo
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
on Monday, September 26, 2005 9:18 AM said:
So i ask what this output?
$a = 4;
$b = 3;
echo $a $b;
echo $a $b;
You just spent 3-5 minutes writing an email and now almost 10 minutes
waiting for a reply to something that would have taken
On 9/26/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
From php manual:
$a $b Shift leftShift the bits of $a $b steps to the left (each step
means multiply by two)
$a $b Shift rightShift the bits of $a $b steps to the right (each step
means divide by two)
So i ask what this output?
$a
[EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Monday, September 26, 2005 1:28 PM
Subject: RE: [PHP] Bitwise operators
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
on Monday, September 26, 2005 9:18 AM said:
So i ask what this output?
$a = 4;
$b = 3;
echo $a $b;
echo $a $b
I tested; I don't want to waste peoples time. Rewriting the question:
this outputs:
c = 32
d = 0
The question is why?
First row is the bit's number and the second row is the bit's value:
#8 | #7 | #6 | #5 | #4 | #3 | #2 | #1
---
128 | 64 | 32 | 16 | 8 |
The second value is the number of spaces to shift, dint realize that.
Thanks for your time Chris.
Angelo
- Original Message -
From: Chris Boget [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; php-general@lists.php.net
Sent: Monday, September 26, 2005 2:02 PM
Subject: Re: [PHP] Bitwise
The situation.
Im currently using a home brewed groups permission code in my site,
but for limited users/groups its ok. Beyond that, the code will take
the fast road to hell.
I started to look in depth at bitwise operations today,
and after much googling, and looking at other code, came up with
Gerard Samuel wrote:
The situation.
Im currently using a home brewed groups permission code in my site,
but for limited users/groups its ok. Beyond that, the code will take
the fast road to hell.
I started to look in depth at bitwise operations today,
and after much googling, and looking at
Marek Kilimajer wrote:
Gerard Samuel wrote:
The situation.
Im currently using a home brewed groups permission code in my site,
but for limited users/groups its ok. Beyond that, the code will take
the fast road to hell.
I started to look in depth at bitwise operations today,
and after much
Gerard Samuel wrote:
Marek Kilimajer wrote:
Gerard Samuel wrote:
The situation.
Im currently using a home brewed groups permission code in my site,
but for limited users/groups its ok. Beyond that, the code will take
the fast road to hell.
I started to look in depth at bitwise operations today,
Marek Kilimajer wrote:
Your checks are something like
if($user['tom'] $perm['read']) echo 'Tom can read';
Only the 3rd bit is checked, all others are ignored and won't do any harm.
Anyway, the clean way of setting permissions is:
$user['tom'] = $perm['execute'] | $perm['write'] | $perm['read'];
On Tuesday 10 June 2003 06:08, Mike Mannakee wrote:
I have a script that is collecting a bunch of information, and storing this
in a database. However, the rows are kinda big and I'm thinking of packing
the information into flag bits, and storing this information in one string
in the
I have a script that is collecting a bunch of information, and storing this
in a database. However, the rows are kinda big and I'm thinking of packing
the information into flag bits, and storing this information in one string
in the database. I'm wondering if I should use mysql's bitwise
Hi,
I'm reading the description of Bitwise Operators on page 81 of Professional
PHP 4, the Wrox book. In the highlighted example on that page, the line of
code...
$user_permissions = CREATE_RECORDS | ALTER_RECORDS;
the description in the book says that this line is building a set of user
]
Date: Mon, 19 Nov 2001 18:02:53 -0800
Subject: [PHP] Bitwise
I have 17 boolean variables which need to be stored in a MySQL database. I
created a SET Column to store each of the boolean values as bits in the
column. I should be able to test for the truth of a particular variable
I have 17 boolean variables which need to be stored in a MySQL database. I
created a SET Column to store each of the boolean values as bits in the
column. I should be able to test for the truth of a particular variable by
checking if the corresponding bit is set.
For example, if the first four
The users on my website all have an access number that is used to give
them access to different parts of the site. Each bit represents a different
part of the site. So, if a user has an access of 10, which is 1010 in
binary, they have access to the parts of the site that are represented by
the
How can I store a large number, value over 8 billion for bitwise
comparison? I have a large set of switchs, getting up to 2 pow 34, and
it goes outside the size of an int, can't set a type that will work.
Nicholas Burke
Strategic Profits Inc.
--
PHP General Mailing List
On Thursday 01 March 2001 20:58, you wrote:
But that would give me a value of a variable variable.
And I need a numerical value so
$var1 ="joe";
$var2 = date( "U" );
echo "$var1$var2";
won't do me any good.
Ahhh. You want to use the mcrypt functions or simply crypt() ?
--
Christian
I have 2 values. The first is a constant while the second is not.
Is the first value a numerical value (real/integer?) or a
string value?
String.
This is what I've come up with and it seems to work pretty ok.
What do you guys think?
(test code to illustrate a point; other than the
I'm wondering how I can do the following (if it is possible at
all):
I have 2 values. The first is a constant while the second is not.
The second value, in this case, is a unix time stamp and as such
will change every time it is set, down to the second.
I need to somehow merge the two values
on 3/1/01 02:34 PM, [EMAIL PROTECTED] split open and melted thusly:
I was thinking I could do something like this:
( var1 var2 )
i think what you want is:
${$var1$var2}
But that would give me a value of a variable variable.
And I need a numerical value so
$var1 ="joe";
$var2 = date( "U"
Hi,
"Boget, Chris" wrote:
I have 2 values. The first is a constant while the second is not.
Is the first value a numerical value (real/integer?) or a string value?
If it is numerical, then one of the things you could do for using a
numerical value of (say) less than 100 could be:
$finalVar
54 matches
Mail list logo