|
Well f. me sideways and call me Dr Dream. You come and tell me that I don't know what I'm saying and immediately say what I said.
Bitwise means EVERYTHING is evaluated and then anded ored noted xored and stuck through the mincer. Binary menas once the result is known it stops. I appologise if using technical terms confussed you but that's it.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
Have a bit more patience with newbies. Of course some of them act dumb -- they're often *students*, for heaven's sake. -- (Terry Pratchett, alt.fan.pratchett)
|
|
|
|
|
Shut the f... up.
Ego non sum semper iustus tamen Ego sum nunquam nefas!
|
|
|
|
|
So if I have this straight, in your example:
if(UsernameTextBox.Text == "Manager" & PasswordTextBox.Text == "Maintenance")
because both arguments are boolean, the '&' is effectively acting just like a '&&' except for being trivially less efficient because it is always doing both of the string compares.
I know in this case you were merely quoting previous post using '&', but even if the non-short-circuit behaviour would be useful sometime, I'd avoid it because it just looks wrong to me. We're in a mixed C++/C# environment here, and I have to be on the lookout for misused '&'s in the code as it is. Allowing for false positives is not in the cards here.
That said, I think you got a raw deal.
|
|
|
|
|
And quite rightly so.
While for booleans, & can work as a logical operator, in all other cases it is bitwise. For consistency, use a single operatopr to represent logical operators throughout, the C# designers (C really) chose && for this purpose.
It may work, but its obfuscated, and should be rejected or corrected by any reasonable code review, regardless of any appeals you make to technical documentation.
|
|
|
|
|
Rob, I think the problem is that you are assuming human beings are rational/reasonable.
Where I am currently, I have to fill out a form and get authorization to fix a simple memory leak. The code base is several million lines of C++, suffering from 20 years of technical debt. Since I already have a reputation for being "too critical about code quality" which causes my input to get knocked down a level or two, I have to bite my tongue a lot.
It's a grand learning experience, but I'll be glad when I figure out what the lesson is!
|
|
|
|
|
The lesson : Never start a fight in the Hall of Shame 
|
|
|
|
|
The "answer" person's assumptions doesn't seem to match with what you have in your message.
Using & is different than using && and the results could be different, depending on what you are comparing. Since both return either true of false, there will not be a difference in the result. (The only difference is how the result is achieved.)
In C and C++, you can "AND items that are not boolean as:
int i, j;
i = 1;
j = 2;
if (i and j) --> result is false (bitwise AND: 1 & 2 yields 0 or false).
if (i and j) --> result is true (logical AND: 1 && 2 yields non-zero or true).
Hope this helps.
|
|
|
|
|
I like this:
#define TRUE (rand() > 0.1 ? TRUE : FALSE) // happy debugging losers

|
|
|
|
|
lol. By the way, you look like Adam Levine[^] of Maroon 5.
Ignorance of the ability brings disability.
|
|
|
|
|
Thanks. Hope it was a compliment;)
|
|
|
|
|
Of course it is.
Ignorance of the ability brings disability.
|
|
|
|
|
|
P1l19r1m wrote: #define TRUE (rand() > 0.1 ? TRUE : FALSE) // happy debugging losers
Shouldn't that just be #define TRUE (rand() > 0.1) ?
I guess I haven't used c++ in a while, but what happens when you use a circular define like that?
|
|
|
|
|
can we do that ??
i will put this in my mate's code 
|
|
|
|
|
You should do it!!! 
|
|
|
|
|
that's pure evil hopefully, there is no switch statement using this constant...
|
|
|
|
|
I've made some kind of mistake "Copypasting" is evil . As MSDN ( http://msdn.microsoft.com/en-us/library/398ax69y.aspx ) claims, rand() function returns a pseudorandom integer in the range 0 to RAND_MAX (32767). So, the preferable way is to use the following "working code":
#define REALLYTRUE 1
#define REALLYFALSE 0
#define TRUE (rand() > (32762/2) ? REALLYTRUE : REALLYFALSE) // happy debugging losers
P.S. If to compile this code:
#define TRUE (rand() > 0.1 ? TRUE : FALSE) // happy debugging losers
we will have an error like:
c:\temp\win32\randex\randex.cpp(19) : error C2065: 'TRUE' : undeclared identifier
But using the new version of code it will be "all right" 
|
|
|
|
|
Actually I liked the original version better as it will work in 32766 out of 32767 cases. Now try to reproduce that odd error! 
|
|
|
|
|
da(14) = i + 1
I have absolutely no idea what it means, but I think it will require that my mind bend.
EDIT: Found this in the same codebase (keep in mind, it's VB.NET):
EDIT 2: Aside from the function names (I replaced sensitive info with "XXX"), I changed nothing:
#Region "Functions to write after main functions"
Public Function GetXXXByXXX(ByVal MyStrin As String) As System.Array
Dim myEmpty As System.Array = Nothing
Return myEmpty
End Function
Public Function GetXXXByXXX(ByVal MyStrin As String) As System.Array
Dim myEmpty As System.Array = Nothing
Return myEmpty
End Function
Public Function getXXX(ByVal MyStrin As String) As System.Array
Dim myEmpty As System.Array = Nothing
Return myEmpty
End Function
#End Region
|
|
|
|
|
Jeeez... don't you recognize art when you see it?
'pleaswe make sure that there is no empty
'we can add even more informations
I like it
(yes|no|maybe)*
|
|
|
|
|
AspDotNetDev wrote: I changed nothing
If you changed Nothing then what did those Functions Return before you changed it?
It's an OO world.
|
|
|
|
|
AspDotNetDev wrote: I changed nothing
one cannot change nothing, it is a very stubborn constant, and that is what makes it so popular.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I suppose you can't break anything if you don't change anything or do anything. Sounds like JSL to me.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
This little gem comes courtesy of Q&A:
If TextBox9.Text > TextBox8.Text Then
GoTo bob
Else : TextBox9.Text = TextBox8.Text
End If
Bob: Lovely, no?
Not only that, but he wanted to know why it didn't put the largest number in TextBox9 when TextBox9 had "999" and TextBox8 had "1000".
Sometimes, I get the feeling we should ask who these people are learning from, and have a "hall of shame" just for them...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
OriginalGriff wrote: GoTo bob
He came to the right place 
|
|
|
|