Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Absolute value without multiplies

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-04 23:05

http://codepad.org/wByY34pA
//its an improvement on my old bithack of x* ((((x >= 0) | 0) << 1) - 1)
void main(){//abs without multiply
int a=-23;// if neg   +2a -a=a if pos -a + 2a=a
int b= ((-a)<<(a<0))+((a)<<(a>0));   
printf("a:%d b:%d",a,b);
}

Name: Anonymous 2011-11-05 9:32

>>21
11011001
2^0 = 1
2^3 = 8
2^4 = 16
2^6 = 64

Sum: 89

1010 0111
2^0 = 1
2^1 = 2
2^2 = 4
2^5 = 32

Sum: 39

Thats why your wrong you fucking idiot. See... I don't think that I need to sit here with you fuckin' dildos anymore!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List