|
|
It's an extension method provided by LINQPad[^].
EDIT: I'm sure James' response wasn't there when I posted this!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm sure James' response wasn't there when I posted this!
Well, at least you got the URL right....
Truth,
James
|
|
|
|
|
Great tip and explanation. I am currently teaching myself C# and this is extremely helpful.
A giraffe is a horse designed by a committee...
... or an Agile methodology...
|
|
|
|
|
I needed the binary AND (was checking a flag register from a custom device) so it would have been a real issue if it did not compile
CALL APOGEE, SAY AARDWOLF
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
"Go ahead, make my day"
|
|
|
|
|
Depending on the correct implementation of the "&" and "&&" operators in a fat class it shouldnt be the same
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Plain C operators - it was a stupid mistake from my part, on the same day I made at least 3 mistakes of >= vs >. It wasn just the day - in fact I'm on sick leave today due to a strong headache I've been coddling since yesterday evening. Probably I was starting to feel it's effects in the morning too
CALL APOGEE, SAY AARDWOLF
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
"Go ahead, make my day"
|
|
|
|
|
Heh, I'd like to use C# but as an embedded developer (using TI DSPs) it's not really an option for me. It's C/C++ or DSP assembly (which nobody in their right mind wants to do!!!!).
|
|
|
|
|
Details! Details!
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
den2k88 wrote: refused to yield the correct expected result.
FTFY
|
|
|
|
|
"If I put in wrong data, will the result be correct?"
CALL APOGEE, SAY AARDWOLF
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
"Go ahead, make my day"
|
|
|
|
|
|
Actually, the result is the same. The side-effects aren't. At least in C#. In C, with it's enforced type-unsafety, the result can be extremey weird and the compiler won't do jack to even warn you.
|
|
|
|
|
No. Example
2 & 4 is 0
2 && is 1 (true)
In that case I needed the first form as I was checking for a flag in a flag register, but mistakenly used the second form due to, well, being the most common (althought not so much in my field, which requires the management of a lot of driverless hardware).
CALL APOGEE, SAY AARDWOLF
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
"Go ahead, make my day"
|
|
|
|
|
That depends on the language. In a strongly typed language, 1 and true aren't the same because one is a number and true is a boolean. So 2&4 is 0 and 2&&4 is 0 as well, however the difference is in side effects.
SomeFunc & SomeOtherFunc will execute both functions with their side-effets, SomeFunc && SomeOtherFunc will stop executing if SomeFunc returns false.
PS: I am talking about C# here which is, unlike C and C++, a strongly-typed language.
|
|
|
|
|
Don't feel bad. I once had a bug based on this very thing that took weeks to find.
Software Zen: delete this;
|
|
|
|
|
How this difference can hurt.
m is length of string = 3;
*b is first character in string say "xyz"
while( *b & m-- ) { b++; } is not the same as while( *b && m-- ) {b++;}
because
while( *b & m-- ) { b++; } fails when *b is null tested AND m is decremented at the same time ergo m is off by 1
while( *b && m-- ) { b++; } fails when *b is null tested. m is not decremented
because of the short circuit test of *b stops the evaluation
ergo m has the correct character count
so yes & and && are not the same so be careful of the logic when using C
|
|
|
|
|
Happy Australia Day?
Hope you all have a good one?
Don't drink too much?
|
|
|
|
|
Are you sure?
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Yes he is?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I thought Shaw was a dead Irish playwright.
veni bibi saltavi
|
|
|
|
|
RyanDev wrote: There are two kinds of people in the world: those who can extrapolate from incomplete data. That's actually deep.
Jeremy Falcon
|
|
|
|
|
|
Pom Pey wrote: Happy Australia Day?
Hope you all have a good one?
Don't drink too much?
I'm not from Australia, but I've heard that on Australia Day, it is not possible to drink too much...
I'm retired. There's a nap for that...
- Harvey
|
|
|
|
|
H.Brydon wrote: I'm not from Australia, but I've heard that on Australia Day, it is not possible to drink too much...
That is true and I'm putting the theory to test as we type.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|