it's also a keen way to store a bunch of preferncess in one place, i.e.
say you want to keep track of read, write, edit and delete permissions
for a bunch of different things, you can save them as one integer and
use the bit operators to deduce whether or not a specific bit is 0 or 1.
you can then break these out into an array to have all the permissions
right there:

read = 1;
write = 2;
edit = 3;
delete = 4;

so if say #sectionPerms# == 6 (or 0110)

you can use the bitwise stuff to deduce:

perms[read] == 0;
perms[write] == 1;
perms[edit] == 1;
perms[delete] == 0;

so you can say,

<cfif perms[read]>
        read this
<cfelse>
        you can't read this
</cfif>

this becomes really handy if you've got lots and lots of different
permissions you wanna set...

-----Original Message-----
From: Matthew R. Small [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 14, 2002 5:17 PM
To: CF-Talk
Subject: RE: OT Thank god for markup


It depends...
If you're using signed integers, which in many cases are not important,
then losing the most sig. bit would have the effect of changing the sign
of the integer.  But Bit shifting is a very fast way of multiplying and
integer dividing by 2.


- Matt Small



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, March 14, 2002 5:04 PM
To: CF-Talk
Subject: OT Thank god for markup

Situation: Studying for Sun Java Cert

Question:
What the !@#$@#$  is the point of a bitwise operator?

can someone give me a reason that i would EVER want to use

101110>>3

and isn't the result

000100

changing the most significant byte to preserve the sign?

OI!



______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to