Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

A bit confused

Jonathan Morris
Registered User
Join date: 5 Jan 2006
Posts: 66
03-03-2006 15:02
Scripts are new to me.
The Linden Scripting Language Guide says; " & returns the bitwise and of left and right hand side."

Can someone please explain what is ment by bitwise ??
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
03-03-2006 15:15
AND is a logic operator. It takes two bits ( a 0 or a 1 ) and returns 1 if they are both 1.

With integers, it does this on each bit..
CODE

a 101010 // As decimal = 42
b 111001 // As decimal = 57
-------------------------------------
101000 // As decimal = 40


This is useful for testing if a specific bit is set, for example, with llGetPermissions...

The if statement is true if the number it evaluates is more than one, so by doing llGetPermissions() & PERMISSION_DEBIT, you can check if it has debit permissions.

I hope this helped.
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
03-03-2006 15:48
From: someone
CODE

a 101010 // As decimal = 10
b 111001 // As decimal = 25
-------------------------------------
101000 // As decimal = 8

er,...
CODE

a 101010 // As decimal = 42
b 111001 // As decimal = 57
-------------------------------------
101000 // As decimal = 40
innit? :o
_____________________
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
03-03-2006 15:57
Good catch, thanks. I just ripped that off the wiki, and neglected to update the values.
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
03-03-2006 15:59
From: Keknehv Psaltery
Good catch, thanks. I just ripped that off the wiki, and neglected to update the values.
*whew* I thought I'd mislearned binary :) Thanks Keknehv.
_____________________