473,657 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do I use 'or' for bitwise operations where in c# I use | ?

Do I use 'or' for bitwise operations where in c# I use | ?
Nov 21 '05 #1
10 2166
Yes

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"Emilio" <[void]> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Do I use 'or' for bitwise operations where in c# I use | ?

Nov 21 '05 #2
"Emilio" <[void]> schrieb:
Do I use 'or' for bitwise operations where in c# I use | ?


'Or' <-> '|' (bitwise)
'OrElse' <-> '||' (logical)

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3
In addition to OHM

'Or' can as well be logical however not in the way as C# that one is
'OrElse'

Cor
Nov 21 '05 #4

O.k. , so bitwise is definitly 'or' , but logical does not have
to be 'OrElse' it can be 'or' as well,
if xy=5 or abc=8 then
msgbox "hello"
end if
'Or' <-> '|' (bitwise)
'OrElse' <-> '||' (logical)


Nov 21 '05 #5
"Emilio" <[void]> schrieb:
O.k. , so bitwise is definitly 'or' , but logical does not have
to be 'OrElse' it can be 'or' as well,
if xy=5 or abc=8 then
msgbox "hello"
end if


Well, in this particular case, 'True' is or'ed (bitwise) with 'True', which
results in 'True'. Behind the scenes a bitwise operation is performed.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #6
I thought that the "OrElse" construct just prevented the short circuit so
the next token would be processed:
A or B orelse c = something.
Thus c is not left undefined.
Aor B else c = something would leave c undefined if A or B is false.
What did I miss?
(Note that I am still coding another rather obscure language so I'm not
attempting to get the syntax correct as I learn the logic)
BobJ
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OV******** ******@TK2MSFTN GP10.phx.gbl...
In addition to OHM

'Or' can as well be logical however not in the way as C# that one is
'OrElse'

Cor

Nov 21 '05 #7
OrElse is a logical operator. It first evaluates the left side of the
comparison statement, and if True does not bother evaluating the right hand
statement because it is futile to do so.

AndAlso does the same thing for an And function, if the left side is True it
wil evaluate the right side, otherwise the final result is false.

HTH

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"BobJ" <bo*@rjsolyn.co m> wrote in message
news:40******** **********@news read2.news.atl. earthlink.net.. .
I thought that the "OrElse" construct just prevented the short circuit so
the next token would be processed:
A or B orelse c = something.
Thus c is not left undefined.
Aor B else c = something would leave c undefined if A or B is false.
What did I miss?
(Note that I am still coding another rather obscure language so I'm not
attempting to get the syntax correct as I learn the logic)
BobJ
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OV******** ******@TK2MSFTN GP10.phx.gbl...
In addition to OHM

'Or' can as well be logical however not in the way as C# that one is
'OrElse'

Cor


Nov 21 '05 #8
Note that the return type is still considered to be boolean (I believe the language definition states that the bitwise operators are defined only for integral
types) - in this case it doesn't matter much what happens behind the scenes - if both operands are boolean you can think about it as a simple boolean
operator, if any of the arguments is numeric, then it will be a bitwise operator.
Also note that Or does not cause evaluation of the second argument not to occur when the first argument is true, unlike OrElse.
--------------------
From: "Herfried K. Wagner [MVP]" <hi************ ***@gmx.at>
References: <#u************ **@TK2MSFTNGP09 .phx.gbl> <#o************ **@TK2MSFTNGP09 .phx.gbl> <OLYWZ37qEHA.27 96 @tk2msftngp13.p hx.gbl>Subject: Re: Do I use 'or' for bitwise operations where in c# I use | ?
Date: Wed, 6 Oct 2004 18:05:48 +0200
Lines: 14
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <eZ************ *@TK2MSFTNGP15. phx.gbl>
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
NNTP-Posting-Host: v208-105.vps.tuwien. ac.at 128.131.208.105
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP15.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:233545
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

"Emilio" <[void]> schrieb:
O.k. , so bitwise is definitly 'or' , but logical does not have
to be 'OrElse' it can be 'or' as well,
if xy=5 or abc=8 then
msgbox "hello"
end if
Well, in this particular case, 'True' is or'ed (bitwise) with 'True', which
results in 'True'. Behind the scenes a bitwise operation is performed.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


Sorry I don't take feature request for WinRes: it belongs to the .NET Framework SDK. I'm a consumer of WinRes, just like you...
--------------------From: Thomas Adams <th************ @gmail.com>
Newsgroups: microsoft.publi c.dotnet.intern ationalization
Subject: RE: How to launch WinRes in full screen mode by another program?
Date: 29 Sep 2004 19:31:46 GMT
Organization : DFN.CIS Senior Customer
Lines: 17
Message-ID: <Xn************ *************** *******@127.0.0 .1>
References: <2q************ @uni-berlin.de> <r3************ **@cpmsftngxa06 .phx.gbl>
X-Trace: news.uni-berlin.de cGk7xWd2iWxkO9H VbF7isQODBzMeOP RUidb0ZHc/H3nGY=
User-Agent: Xnews/06.08.25
X-Converter: MorVer Version 1.0.305
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG XA03.phx.gbl!TK 2MSFTNGP08.phx. gbl!newsfeed00. sul.t-online.de!newsf eed01.sul.t-online.de!t-online.de!fu- berlin.de!uni-berlin.de!not-for-mailXref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.intern ationalization: 947
X-Tomcat-NG: microsoft.publi c.dotnet.intern ationalization

Hi

Your assumption is correct. I did not want to call out its long name
since I didn't know if that could be regarded as breach of NDA. :)

Thanks for the explanation. Do you take feature requests for WinRes?
I'd like to see a "remember last size and location" some day...

~T.

xu*@online.mic rosoft.com (Xu Yang[MSFT]) wrote:
--

[Formerly appended fullquote was nuked by morver,
the versatile morphing server.]

I'm afraid that LocStudio (when you say LS, I assume you are using LocStudio) does not have the option, and WinRes does not remember its size and
location when it was shut down.
If you are trying to call it in your own application, you can always use ProcessWindowSt yle.Maximized when you start the process.

--------------------From: Thomas Adams <me*@privacy.ne t>
Newsgroups: microsoft.publi c.dotnet.intern ationalization
Subject: How to launch WinRes in full screen mode by another program?
Date: 11 Sep 2004 21:26:17 GMT
Organization : DFN.CIS Senior Customer
Lines: 9
Message-ID: <2q************ @uni-berlin.de>
X-Trace: news.uni-berlin.de 9sj2ViefNkwlw4t mA89WfA6mie8fmr CfbXqlIJqRehUb0 =
User-Agent: Xnews/06.08.25
X-Face: #Rk@TOQ|^!ZG|&z 6lA@-CY>/xB[Ei1mG*&S.+A5z;N g?3OxX[#DVZw!"o!c`S|p: (zsX-EkdZZ(IVnFRTX%! :Sv^L&Gk~s]vJ@Z~%Rm@G]fr*r2P}u5 *&k/-_2+&Qowj6hiJ1b$ ^JQf:uy9456HIdK q*B`NC##kyO,>7" Ztnav+=71b*"E+D Ime;{i&)ii{#6e? i8P,1Xpc[q0}i:Tm];B1X-Converter: MorVer Version 1.0.305
Path: cpmsftngxa10.ph x.gbl!TK2MSFTFE ED01.phx.gbl!TK 2MSFTNGP08.phx. gbl!newsfeed00. sul.t-online.de!newsf eed01.sul.t-online.de!t-online.de!fu- berlin.de!uni-berlin.de!not-for-mailXref: cpmsftngxa10.ph x.gbl microsoft.publi c.dotnet.intern ationalization: 902
X-Tomcat-NG: microsoft.publi c.dotnet.intern ationalization

Hi

Let's imagine you're using a translation environment (LS) that's
launching WinRes every now and then. Is it possible to open WinRes in
full screen mode in this case? It's quite annoying that it doesn't
remember if I switch it to full screen mode the next time it is invoked.

thanks,
Thomas


Nov 21 '05 #9
> Also note that Or does not cause evaluation of the second
argument not to occur when the first argument is true, unlike OrElse.


'OrElse' will provide short-circuiting, which means that 'expression2' in
'expression1 OrElse expression2' will not be evaluated if 'expression1' is
already 'True'. 'Or' will evaluate both, 'expression1' and 'expression2',
independent from the result of 'expression1''s evaluation.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2480
by: Mike Hodkin | last post by:
As a beginning student of C++, books reference "bitwise operators" and give brief examples, but I have not read a good explanation of what they are used for. One reference mentioned that they are used in hardware programming. Are they used very often in routine C/C++ programming, and what for? thanks, MJH
24
2705
by: Alex Vinokur | last post by:
Consider the following statement: n+i, where i = 1 or 0. Is there more fast method for computing n+i than direct computing that sum? -- Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html
2
7526
by: Joe Gonzalez | last post by:
Is it possible to perform bitwise operations in selects in DB2 8.1? In postgres I can say something like SELECT ... FROM <sometable> WHERE RecFlags && 0x08 <> 0 to get a bitwise and operation. I can't find anything similar in the db2 SELECT docs. Is there a built-in function that can perform the bitwise operation? Thanks in advance for any info. Joe Gonzalez
6
8971
by: jas_lx | last post by:
The basic understanding of what bitwise operators (& ^ | >> << ) comes fairly simple, as long as one has a fundamental understanding of bits, bytes and binary. Having done some Win32 programming in straight C, the Win32 API sends windows messages to applications with various settings stored in bit fields, in which case changing the settings of the message is a matter of using the bitwise operators. This was a good practical example of...
8
6931
by: Paul E Collins | last post by:
Suppose I have a few Keys objects: Keys k1 = Keys.V; // V Keys k2 = Keys.Control | Keys.V; // Ctrl+V Keys k3 = Keys.Shift | Keys.J; // Shift+J I need to determine which of these include the Keys.V element, regardless of any other keys. I know it will be a bitwise comparison, but I can't work out the correct syntax to use.
32
3899
by: John Davis | last post by:
One interesting observation I found is VB6 or VB.NET overloads = opeartor. i.e. = operator has 2 meanings. Case 1: relational operator. In other languages, usually use == instead. If a = b Then statement Case 2: assignment operator a = b Just my observation. Please discuss.
29
5938
by: Carl Banks | last post by:
Anyone with me here? (I know the deadline for P3 PEPs has passed; this is just talk.) Not many people are bit-fiddling these days. One of the main uses of bit fields is flags, but that's not often done in Python because of keyword arguments and dicts, which are lot more versatile. Another major use, talking to hardware, is not something oft done in Python either. It seems like this occasional usage wouldn't justify having built-in...
2
1693
by: snorble | last post by:
I started creating a simple "bits" class, intended to act like a array of bits. This was my initial idea, basically just overriding the string representation to display the bitmask (so far): class bits(long): def __str__ (self): s = '' if self == 0L: s += '-' else:
10
1773
by: Rob Wilkerson | last post by:
I'm attempting to do some work around existing code that uses bitwise operations to manage flags passed into a function and I'm quite frankly unequipped to do so. I've never done much with bitwise operations and all the reading I've done today doesn't appear to be helping me much. I'm hoping someone here can provide a remedial lesson. Given the following constants: define('FLAG_1, 1); define('FLAG_2', 2); define('FLAG_3', 4);
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.