[PHP] Bitwise solution?

2001-03-01 Thread Boget, Chris

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 so that the new, merged 
value would be as (semi) unique as the timestamp value.

I was thinking I could do something like this:

( var1 & var2 )

But that generates an identical value every time.

Is there a way I can do this?
And no, I cannot just use the timestamp value. :P  And microtime()
isn't really an option either. :(

Any help at all would be greatly appreciated! :)

Chris



[PHP] bitwise comparison

2001-05-18 Thread nick

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 (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Bitwise solution?

2001-03-01 Thread Boget, Chris

> 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" );

echo "$var1$var2";

won't do me any good.

:/

I've a very odd predicament...

Chris



Re: [PHP] Bitwise solution?

2001-03-01 Thread Harshdeep S Jawanda

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 = ($var2 * 10) + $var2;

This is one of the simplest things you could do and meant only as a
rough example. A faster way would be to right-shift by 4 (if that can be
done in PHP) instead of multiplying by 10. This well essentially
multiply the number by 16.

I am relatively new to PHP, so the syntax I have used may not be
correct. Sorry about that.

Does this come anywhere close to what you would like to do?

--
Regards,
Harshdeep Singh Jawanda.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Bitwise solution?

2001-03-02 Thread Christian Reiniger

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 Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

The use of COBOL cripples the mind; its teaching should, therefore,
be regarded as a criminal offence.

- Edsger W. Dijkstra

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Bitwise solution?

2001-03-02 Thread Boget, Chris

> > 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 XORing, not 
what I'm actually going to do with the "live" code)



$uniqueArray = array();
for( $i = 0; $i <= 100; $i++ ) {
$certnum = date( "U" );  // what the second variable is always set
to

if( $certnum == $lastCertNum ) {
sleep( 1 );

}

$uid = ( $uid == "nsa000" ) ? "mdb000" : "nsa000";  // sample first
variable

$uniqueNum = ( hexdec( $uid ) ^ $certnum );

echo "$uid ^ $certnum = $uniqueNum
\n"; if( in_array( $uniqueNum, $uniqueArray )) { echo "Not a unique number!

\n"; } $uniqueArray[] = $uniqueNum; flush(); $lastCertNum = $certnum; } Chris

[PHP] bitwise AND is acting strange

2001-07-22 Thread Jeremy

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 second and fourth bit. You know, standard bit masking stuff.

So the part of the site that is represented by the second bit has a value of
2 (0010), and the part that is represented by the fourth bit has a value of
8 (1000)

BUT, for some reason when I do (2 & 10) its giving me a result of zero, when
I believe it should be doing (0010 & 1010) and giving me an answer of 0010
which is 2 in decimal.

With users with an access other than 10, say 9, or 8, or 7, it seems to
behave normally. What is going on? Is it treating the 10 as a binary 2?
These access values are stored in a mysql table as a standard INT, and they
are not UNSIGNED or BINARY.

Am I missing something?

Jeremy







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]