Xojo Conferences
XDCMay2019MiamiUSA

AND NOT, BIT() (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: Help! With Favorites
Next thread: Re: please help me: webkit problem - RealBasic MAC -


Re: Balloons   -   Terry Ford
  AND NOT, BIT()   -   John McKernon
   Re: AND NOT, BIT()   -   Joseph J. Strout
    Re: AND NOT, BIT()   -   John McKernon
     Re: AND NOT, BIT()   -   Seth Willits
     Re: AND NOT, BIT()   -   Joseph J. Strout
   Re: AND NOT, BIT()   -   Seth Willits
   Re: AND NOT, BIT()   -   Phil M
    Re: AND NOT, BIT()   -   John McKernon

AND NOT, BIT()
Date: 08.02.05 04:26 (Mon, 07 Feb 2005 22:26:25 -0500)
From: John McKernon
Dear fellow listers,

I've just started with RealBasic, coming over from Visual Basic and
FutureBasic, and I haven't been able to find RB equivalents for these:

X AND NOT 31

(This is a bit operation, the "X" is an integer)

X= Bit(3) in FutureBasic,

X= 2^3 in Visual Basic

(Both of these do the same thing, set bit 3)

Any suggestions?

- John McKernon

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: AND NOT, BIT()
Date: 08.02.05 04:33 (Mon, 7 Feb 2005 21:33:06 -0600)
From: Joseph J. Strout
At 10:26 PM -0500 2/7/05, John McKernon wrote:

>X AND NOT 31
>
>(This is a bit operation, the "X" is an integer)

See the Bitwise module in the language reference (which claims it to
be a class -- but consider it a module).

>X= Bit(3) in FutureBasic,

There's no function like that in RB, but...

>X= 2^3 in Visual Basic

this is perfectly valid REALbasic code. Probably not the most
efficient way to set the third bit, but it works. (More efficient
might be Bitwise.ShiftLeft(1,2), and most efficient would be a
look-up table.)

Best,
- Joe

Re: AND NOT, BIT()
Date: 08.02.05 05:48 (Mon, 07 Feb 2005 23:48:23 -0500)
From: John McKernon
>> X= 2^3 in Visual Basic
>
> this is perfectly valid REALbasic code.

Hmmm... I didn't find the caret as an operator in the language reference, so
I assumed it wasn't valid.

Nothing like an 'interesting' first day with RB...;)

Thanks!

- John

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: AND NOT, BIT()
Date: 08.02.05 07:37 (Mon, 7 Feb 2005 22:37:09 -0800)
From: Seth Willits
On Feb 7, 2005, at 8:48 PM, John McKernon wrote:

>>> X= 2^3 in Visual Basic
>>
>> this is perfectly valid REALbasic code.
>
> Hmmm... I didn't find the caret as an operator in the language
> reference, so
> I assumed it wasn't valid.
>
> Nothing like an 'interesting' first day with RB...;)

It's news to me and I've been here for years. Joe, what other kind of
secrets are you hiding?


Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic

"Your friend is the person who knows all about you and still likes you."
-- Elbert Green Hubbard
------------------------------------------------------------------------
---

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: AND NOT, BIT()
Date: 08.02.05 15:39 (Tue, 8 Feb 2005 08:39:07 -0600)
From: Joseph J. Strout
At 10:37 PM -0800 2/7/05, Seth Willits wrote:

>>Hmmm... I didn't find the caret as an operator in the language reference, so
>>I assumed it wasn't valid.
>>
>>Nothing like an 'interesting' first day with RB...;)
>
>It's news to me and I've been here for years. Joe, what other kind
>of secrets are you hiding?

None, but you may have to occasionally read the release notes. :)
This was added recently, in 5.5 I believe. I don't know why it's not
listed under "Operators" in the LR, but we have some things in the
works that will allow us to correct this sort of oversight in the
docs more easily.

In older versions of RB, you'd just use the Pow function, which does
the same thing.

Best,
- Joe

Re: AND NOT, BIT()
Date: 08.02.05 04:39 (Mon, 7 Feb 2005 19:39:05 -0800)
From: Seth Willits
On Feb 7, 2005, at 7:26 PM, John McKernon wrote:

> X AND NOT 31
> (This is a bit operation, the "X" is an integer)
> ...

See the Bitwise class methods.

Bitwise.BitAnd
Bitwise.BitOr
Bitwise.BitXor
Bitwise.OnesComplement
Bitwise.ShiftLeft
Bitwise.ShiftRight


Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic

"When you are courting a nice girl an hour seems like a second. When you
sit on a red-hot cinder a second seems like an hour. That's
relativity."
-- Albert Einstein
------------------------------------------------------------------------
---

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: AND NOT, BIT()
Date: 08.02.05 04:42 (Mon, 7 Feb 2005 19:42:34 -0800)
From: Phil M
On Feb 7, 2005, at 7:26 PM, John McKernon wrote:

> Dear fellow listers,
>
> I've just started with RealBasic, coming over from Visual Basic and
> FutureBasic, and I haven't been able to find RB equivalents for these:
>
> X AND NOT 31
>
> (This is a bit operation, the "X" is an integer)

This is a little different... see below...

> X= Bit(3) in FutureBasic,
>
> X= 2^3 in Visual Basic
>
> (Both of these do the same thing, set bit 3)

NewInt = Bitwise.BitAnd(x, &h4)

&h1 = Bit 1
&h2 = Bit 2
&h4 = Bit 3
&h8 = Bit 4
&h10 = Bit 5
&h20 = Bit 6
&h40 = Bit 7
&h80 = Bit 8
(and so on)

Back to "X And Not 31". This is exactly the opposite of BitAnd. This
means that you want to turn *off* the bottom 5 bits. You can express
this in REALbasic like this:

NewInt = Bitwise.BitAnd(x, Bitwise.OnesComplement(31))

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: AND NOT, BIT()
Date: 08.02.05 05:44 (Mon, 07 Feb 2005 23:44:15 -0500)
From: John McKernon
> Back to "X And Not 31". This is exactly the opposite of BitAnd. This
> means that you want to turn *off* the bottom 5 bits. You can express
> this in REALbasic like this:
>
> NewInt = Bitwise.BitAnd(x, Bitwise.OnesComplement(31))

Ah! So that's what OnesComplement is useful for!

Many thanks -

- John

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>