Does anyone know if Microsoft will have support for binary operations such as:
Dim a as short
if (a and %1100110011110000) = 0, then
..........
Dennis in Houston 28 1100
* =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit: Does anyone know if Microsoft will have support for binary operations such as:
Dim a as short if (a and %1100110011110000) = 0, then
AFAIK no.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Sorry to hear that. Direct bitwise with the various operators is one of the few remaining weakness of VB.
--
Dennis in Houston
"Herfried K. Wagner [MVP]" wrote: * =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit: Does anyone know if Microsoft will have support for binary operations such as:
Dim a as short if (a and %1100110011110000) = 0, then
AFAIK no.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
I am confused here, i thought it did!
dim a as integer = 15
dim b as integer = 3
dim r as integer
r = a and b
' r now = 3 isnt thsi what you want?
puzzled
guy
"Herfried K. Wagner [MVP]" wrote: * =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit: Does anyone know if Microsoft will have support for binary operations such as:
Dim a as short if (a and %1100110011110000) = 0, then
AFAIK no.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
> > Dim a as short if (a and %1100110011110000) = 0, then
AFAIK no.
There will be some more bitwise operating I thought or better there is
already, however you knows this better to me, so I think that this
explanation is to short.
(As well for me of course, to clean maybe a misunderstanding from me)
Cor
No, he wants to use Binary literals in his expressions like with hex for
example, &HFF. He wants to write %11111111
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"guy" <gu*@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com... I am confused here, i thought it did!
dim a as integer = 15 dim b as integer = 3 dim r as integer r = a and b ' r now = 3 isnt thsi what you want?
puzzled
guy
"Herfried K. Wagner [MVP]" wrote:
* =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit: Does anyone know if Microsoft will have support for binary operations
such as: Dim a as short if (a and %1100110011110000) = 0, then
AFAIK no.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
The only thing I can suggest is that you write a class for converting binary
represented string values into shorts something like.
PSEUDO!
Class ConvertMe
Public Function ToShort( ByVal str as String ) as short
Dim c as MyShort
'Get the string is valid
'Else throw an exception
For each c in str
MyShort << 1
MyShort = MyShort And ValueOf( c )
End Function
Return c
End Class
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com... Does anyone know if Microsoft will have support for binary operations such
as: Dim a as short if (a and %1100110011110000) = 0, then ......... Dennis in Houston
* "Cor Ligthert" <no**********@planet.nl> scripsit: Dim a as short if (a and %1100110011110000) = 0, then
AFAIK no.
There will be some more bitwise operating I thought or better there is already, however you knows this better to me, so I think that this explanation is to short.
Sure, but there will not be binary number literals, like '&B10010101'.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
* =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit: Sorry to hear that. Direct bitwise with the various operators is one of the few remaining weakness of VB.
I am currently discussing with some folks about this idea. Basically I
like it, but there are problems associated with it too. Consider this
code:
\\\
If (Foo And &B11101010101110101011101010010010 = &B11101010101110101011101010010010 Then
...
End If
///
A little typo and you will get a wrong result...
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
> Sure, but there will not be binary number literals, like '&B10010101'.
Good explanation.
I hope that we both agree that this would be crazy in a language like VBnet?
Thanks
Cor
* "Cor Ligthert" <no**********@planet.nl> scripsit: Sure, but there will not be binary number literals, like '&B10010101'.
Good explanation.
I hope that we both agree that this would be crazy in a language like VBnet?
I would allow binary integer literals:
\\\
<Flags()> _
Public Enum Goo
None = &B0
A = &B1
B = &B10
C = &B100
D = &B1000
End Enum
///
;-)
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Herfried,
I normally use: <Flags()> _ Public Enum Goo None = 0 A = 1 << 0 B = 1 << 1 C = 1 << 2 D = 1 << 3 End Enum
Where the 1 is shifted over the bit position.
I agree I've wanted binary constants once or twice.
Just a thought
Jay
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl... * "Cor Ligthert" <no**********@planet.nl> scripsit: Sure, but there will not be binary number literals, like '&B10010101'. Good explanation.
I hope that we both agree that this would be crazy in a language like
VBnet? I would allow binary integer literals:
\\\ <Flags()> _ Public Enum Goo None = &B0 A = &B1 B = &B10 C = &B100 D = &B1000 End Enum ///
;-)
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:Ou*************@TK2MSFTNGP09.phx.gbl... MyShort = MyShort And ValueOf( c )
Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only
place I could find this was under JScript[.NET].
Hi Jeff,
To help Terry a little bit, you quoted him (probably by accident) wrong PSEUDO! bla bla bla MyShort = MyShort And ValueOf( c )
Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only place I could find this was under JScript[.NET].
:-)
Cor
No it's Pseudo code.
Basically what I am trying to impart is that you could construct a number
from a string representing a binary number so in your test u could have
written.
if ( a And ToShort( "01000100100100") ) Then
' Do Stuff
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:Ou*************@TK2MSFTNGP09.phx.gbl...
MyShort = MyShort And ValueOf( c )
Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only place I could find this was under JScript[.NET].
* "Jeff Johnson [MVP: VB]" <i.***@enough.spam> scripsit: "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:Ou*************@TK2MSFTNGP09.phx.gbl...
MyShort = MyShort And ValueOf( c )
Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only place I could find this was under JScript[.NET].
It's pseudo code, or in other words, a method that takes a string
consisting of "0" and "1" characters. 'ValueOf' would return its
integer value.
Still, performance will be bad, especially for longer strings. Natively
supporting binary number /literals/ that are converted at compile-time
would be a far better approach.
Currently, you can use this code to get the behavior of 'ValueOf':
\\\
Public Function ValueOf(ByVal BinaryString As String) As Integer
Return Convert.ToInt32(BinaryString, 2)
End Function
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Jay,
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit: I normally use:
<Flags()> _ Public Enum Goo None = 0 A = 1 << 0 B = 1 << 1 C = 1 << 2 D = 1 << 3 End Enum Where the 1 is shifted over the bit position.
Full ACK. I prefer this way too.
I agree I've wanted binary constants once or twice.
I just throught in which situations binary number literals would make
sense, and the case of a little enum was one of the most useful cases I
was able to find. So, in everyday programming, binary number literals
don't make much sense, which still doesn't mean that it should not be
possible to use them ;-).
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
> Full ACK. I prefer this way too.
I agree I've wanted binary constants once or twice.
I just throught in which situations binary number literals would make sense, and the case of a little enum was one of the most useful cases I was able to find. So, in everyday programming, binary number literals don't make much sense, which still doesn't mean that it should not be possible to use them ;-).
Again why? Because sometimes to much is no benefit, it can make simple
things suddenly more difficult. Example OR and ELSE.
Cor
Yes, I agree completely, however, in the absence of those binary literals,
if the OP wanted to be able to write out a string of ones and zeros in the
programming then this is one option available now.
Given that Visual Basic, has little support for accessing the pc's IO, its
probably not much of a requirement.
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:el*************@TK2MSFTNGP09.phx.gbl... * "Jeff Johnson [MVP: VB]" <i.***@enough.spam> scripsit: "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:Ou*************@TK2MSFTNGP09.phx.gbl...
MyShort = MyShort And ValueOf( c )
Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only place I could find this was under JScript[.NET].
It's pseudo code, or in other words, a method that takes a string consisting of "0" and "1" characters. 'ValueOf' would return its integer value.
Still, performance will be bad, especially for longer strings. Natively supporting binary number /literals/ that are converted at compile-time would be a far better approach.
Currently, you can use this code to get the behavior of 'ValueOf':
\\\ Public Function ValueOf(ByVal BinaryString As String) As Integer Return Convert.ToInt32(BinaryString, 2) End Function ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
Actually, it's one of those things you almost never want to do, so I was
suprised that this overloaded ToInt32 had no less than ( 19 ) overloads and
one of them did the trick, well spotted H.
Regards - OHM
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eq**************@TK2MSFTNGP09.phx.gbl... Yes, I agree completely, however, in the absence of those binary literals, if the OP wanted to be able to write out a string of ones and zeros in the programming then this is one option available now.
Given that Visual Basic, has little support for accessing the pc's IO, its probably not much of a requirement.
--
OHM ( Terry Burns ) . . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:el*************@TK2MSFTNGP09.phx.gbl... * "Jeff Johnson [MVP: VB]" <i.***@enough.spam> scripsit: "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:Ou*************@TK2MSFTNGP09.phx.gbl...
> MyShort = MyShort And ValueOf( c )
Is ValueOf() somthing you wrote yourself? I looked in MSDN and the
only place I could find this was under JScript[.NET].
It's pseudo code, or in other words, a method that takes a string consisting of "0" and "1" characters. 'ValueOf' would return its integer value.
Still, performance will be bad, especially for longer strings. Natively supporting binary number /literals/ that are converted at compile-time would be a far better approach.
Currently, you can use this code to get the behavior of 'ValueOf':
\\\ Public Function ValueOf(ByVal BinaryString As String) As Integer Return Convert.ToInt32(BinaryString, 2) End Function ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
* Cor Ligthert <no**********@planet.nl> scripsit: Full ACK. I prefer this way too.
I agree I've wanted binary constants once or twice.
I just throught in which situations binary number literals would make sense, and the case of a little enum was one of the most useful cases I was able to find. So, in everyday programming, binary number literals don't make much sense, which still doesn't mean that it should not be possible to use them ;-).
Again why? Because sometimes to much is no benefit, it can make simple things suddenly more difficult. Example OR and ELSE.
I am not against binary integer number literals...
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... No it's Pseudo code.
Mental block. I virtually never use pseudo code myself and the rest of the
stuff you looked so "real" it didn't occur to me, regardless of the large
PSUEDO! in your post....
Herfried, I just throught in which situations binary number literals would make
I like the term "binary number literals" better then my "binary
constants"...
Jay
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uT**************@tk2msftngp13.phx.gbl... Jay,
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit: I normally use:
<Flags()> _ Public Enum Goo None = 0 A = 1 << 0 B = 1 << 1 C = 1 << 2 D = 1 << 3 End Enum
Where the 1 is shifted over the bit position.
Full ACK. I prefer this way too.
I agree I've wanted binary constants once or twice.
I just throught in which situations binary number literals would make sense, and the case of a little enum was one of the most useful cases I was able to find. So, in everyday programming, binary number literals don't make much sense, which still doesn't mean that it should not be possible to use them ;-).
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
LOL
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
No it's Pseudo code.
Mental block. I virtually never use pseudo code myself and the rest of the stuff you looked so "real" it didn't occur to me, regardless of the large PSUEDO! in your post....
I quickly knocked up this implementation. However, as H pointed out,
Convert.ToShort("000000000000100",2) Does the same thing and I tested the
performance, its four times quicker than my code as you might expect. But
here it is for interest sake.
Public Function ToShort(ByVal str As String) As Short
Dim x As Int16
Dim i As Int16
For i = 0 To 14
If Char.GetNumericValue(str, i) = 1 Then
x = x Or &H1
End If
x = x << 1
Next
Return x
End Function
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
No it's Pseudo code.
Mental block. I virtually never use pseudo code myself and the rest of the stuff you looked so "real" it didn't occur to me, regardless of the large PSUEDO! in your post....
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit: I just throught in which situations binary number literals would make
I like the term "binary number literals" better then my "binary constants"...
Well, I didn't know the right term to use and then I took a look in the
documentation to use an appropriate term ;-).
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
I believe one of the rules of higher level languages is that the higher
level language 'must' accomodate all objects found in the lower level
languages (here: assembly). Keep in mind this code is used primarily by
machines, not by humans.
The Machine Imperatives http://www.dennisys.com/
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:el*************@TK2MSFTNGP09.phx.gbl... * "Jeff Johnson [MVP: VB]" <i.***@enough.spam> scripsit: "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:Ou*************@TK2MSFTNGP09.phx.gbl...
MyShort = MyShort And ValueOf( c )
Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only place I could find this was under JScript[.NET].
It's pseudo code, or in other words, a method that takes a string consisting of "0" and "1" characters. 'ValueOf' would return its integer value.
Still, performance will be bad, especially for longer strings. Natively supporting binary number /literals/ that are converted at compile-time would be a far better approach.
Currently, you can use this code to get the behavior of 'ValueOf':
\\\ Public Function ValueOf(ByVal BinaryString As String) As Integer Return Convert.ToInt32(BinaryString, 2) End Function ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
Oops: Here's a URL on Imperative Programming: http://www.wordiq.com/definition/Imperative_programming
"DND" Do not dismiss as unimportant; ever. - me
"Dennis D." <te**@dennisys.com> wrote in message
news:ef*************@TK2MSFTNGP09.phx.gbl... I believe one of the rules of higher level languages is that the higher level language 'must' accomodate all objects found in the lower level languages (here: assembly). Keep in mind this code is used primarily by machines, not by humans.
The Machine Imperatives http://www.dennisys.com/
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:el*************@TK2MSFTNGP09.phx.gbl... * "Jeff Johnson [MVP: VB]" <i.***@enough.spam> scripsit: "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:Ou*************@TK2MSFTNGP09.phx.gbl...
> MyShort = MyShort And ValueOf( c )
Is ValueOf() somthing you wrote yourself? I looked in MSDN and the
only place I could find this was under JScript[.NET].
It's pseudo code, or in other words, a method that takes a string consisting of "0" and "1" characters. 'ValueOf' would return its integer value.
Still, performance will be bad, especially for longer strings. Natively supporting binary number /literals/ that are converted at compile-time would be a far better approach.
Currently, you can use this code to get the behavior of 'ValueOf':
\\\ Public Function ValueOf(ByVal BinaryString As String) As Integer Return Convert.ToInt32(BinaryString, 2) End Function ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
Excuse me for interupting:
Time flies when you don't know what you're doing
That is a great saying!
Where do you get your tag lines?
Dennis D. http://www.dennisys.com/
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl... LOL
--
OHM ( Terry Burns ) . . . One-Handed-Man . . .
Time flies when you don't know what you're doing
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message news:%2****************@tk2msftngp13.phx.gbl... "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
No it's Pseudo code.
Mental block. I virtually never use pseudo code myself and the rest of
the stuff you looked so "real" it didn't occur to me, regardless of the
large PSUEDO! in your post....
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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,...
| |