Any ways to make this shorter?
#7

oh, i see my mistake. i dont know why i assumed the values as bits, and accidently thought ahead w/o reading the variable names: teammemberS indeed implicits an integer, my wrong.

oh, yes, i tested it - but only with bits. when:
Код:
a=0xb1; b=0xb0; c=0xb1;
and the operator | ,aka "logical and", outputs a 1 if ANY of those bits equals 1, then
Код:
if (0 < a|b|c)
equals
Код:
if (0 < 1) //but equals 0 when a=0, b=0, c=0, 0and0and0=0...
while, with integers:
Код:
a=16; b=128; c=51;
a|b|c equals 16|128|51 //and HERE i stopped using my brain. i feel forced to explain my mistake...
Код:
a=0xb 00010000 //16
b=0xb 10000000 //128
c=0xb 00110011 //51
the fail output of my suggestion would have been
Код:
result=0xb 10110011 //179. this number appears from thin air, right? it doesnt:
^ thats 128+32+16+2+1=179, or 16+128+(51-16=35)=179.
the extra 35 is made of the differenting 3/4 bits in 51: 4 bits in 51 | 1 bit in 16, are adding 3 bits only:
Код:
(51-16=35) //equals
0xb 001 1 0011 //51
-
0xb 000 1 0000 //16
=
0xb 001 0 0011 //35
watch the missing bit #4 (valued 16), its gone!

i guess i will ask before i give rushed answers, especially when i dont get the problem right - sorry for causing confusion.

for those who didnt expect an excuse: its not my fault, its the integers'...

@******: "yes", and "yes". failed nevertheless. how/why? an honest answer would force you to censor it ^^
@FalconX: yes, this operator gets used in my fingerprint include/filterscript in my signature, its working excellent in the proper environment ^^
Reply


Messages In This Thread
Any ways to make this shorter? - by Dan. - 17.08.2012, 10:18
Re: Any ways to make this shorter? - by FalconX - 17.08.2012, 10:20
Re: Any ways to make this shorter? - by Dan. - 17.08.2012, 10:21
Re: Any ways to make this shorter? - by Babul - 17.08.2012, 11:10
Re: Any ways to make this shorter? - by FalconX - 17.08.2012, 11:52
AW: Re: Any ways to make this shorter? - by Nero_3D - 17.08.2012, 12:06
Re: Any ways to make this shorter? - by Babul - 18.08.2012, 10:42

Forum Jump:


Users browsing this thread: 1 Guest(s)