pouët.net

Go to bottom

category: code [glöplog]
How (for concreteness, 32 bits):
(0 <= x)? x:-x
-x = ~(x - 1)
If x < 0 then -x = ~(x - (x SHL 31)) because, in 2's complement, x's bit 31 = 1
If 0 <= x then x = (x - (x SHL 31)) because then, x's bit 31 = 0
Now, ~y = (0xffffffff)^y. So,
if x < 0 then -x = (x SAR 31)^(x - (x SHL 31)) because then x SAR 31 = 0xffffffff
If 0 <= x then x = (x SAR 31)^(x - (x SHL 31)) because then x SAR 31 = 0 and 0^y = y.
Hence, both cases can be expressed by one formula: (x SAR 31)^(x - (x SHL 31)).
Code:Vector3 rowanpos = m_v2 + (m_v1 - m_v2).norm() * m_berryDistance;

Code:setne dl
Code: #include <stdio.h> void main() { int n; n=666; // the C preprocessor is your friend, my friend... \ n=42; printf("n=%d\n",n); }
Code:nvhost_pushbuf_push(pb, NVHOST_OPCODE_INCR(0x121, 0x03)); nvhost_pushbuf_relocate(pb, gr3d->attributes, 0x60, 0); nvhost_pushbuf_push(pb, 0xdeadbeef); nvhost_pushbuf_push(pb, 0xec000000); nvhost_pushbuf_push(pb, 0x00200000);
d=22,D=d*d;A=300;M=Math;t=K=0;f='function P(v0,v1,v2,v3){Z=0;';for(i=0;i<4;i++)f+='if(V[B+v'+i+'].r <0)Z|='+(1<<i)+';';for(q in U=[51278,40221,55500,35292,58923,52810,59722,60745,59465,31544]){u=U[q];F=[];l=u ;for(i=0;i<3;i++){l>>=4;F.push('{G:(C=V[v'+(l&3)+'+B] ).G+(Q=-C.r/((Y=V[v'+(l>>2&3)+'+B]).r-C.r))*(Y.G-C.G),H:C.H+Q *(Y.H-C.H)}')}f+='if(Z=='+(u&15)+'||Z=='+(~u&15) +')T.push(['+F.join()+']);'}f+='}';eval(f);V=[];for (i=0;i<d*D;i++)V[i]=({x:((i/D)-(d-1)/2)/d,y:-((i%d)-(d-1)/2)/d,z:-(((i/d)%d)-( d-1)/2)/d});setInterval(function(){t++;X=[];for(i=0;i<24;i++)X[i]=M.sin(((t/10 )+(i*33%13))/(0.5+((i*91%12)*0.1)))*0.30;for(i in V){V[i].G=(V[i].x/(V[i].z+0.8))*A+A;V[i].H=(V[i].y/(V[i].z+0.8))*A+A;v=0;for(j=0 ;j<24;j+=3){x=V[i].x+X[j];y=V[i].y+X[j+1];z=V[i].z+X[j+2];v+=1/(x*x+y*y+z*z)}V [i].r=v/16-6}T=[];for(B=0;B<M.pow(d-1,3);B++){E=D+d;W=d+1;R=E+1;P(0,W,d,E);P(0 ,W,R,E);P(0,D,R,E);P(0,R,1,W);P(0,R,1,D);P(D+1,R,1,D)}c.width=c.height=600;for(i in T){S=T[i];a.beginPath();for(j in S)a.lineTo(S[j].G,S[j].H);a.stroke()}},20)
Code:loop fat
Code:c = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!?.,"[i];

Living on the edge of C..
Code:main = putStrLn \$ a ++ show a where a = "main = putStrLn \$ a ++ show a where a = "
From http://hackers-delight.org.ua/065.htm:

Code: Divide by 3 li M,0x55555556 Load magic number, (2**32+2)/3. mulhs q,M,n q = floor(M*n/2**32). shri t,n,31 Add 1 to q if add q,q,t n is negative. muli t,q,3 Compute remainder from sub r,n,t r = n - q*3.
Code: #!/opt/wmi/bin/perl # griffiol - 23.03.2013 use strict; use warnings; if (\$#ARGV+1 != 1) { print "Usage: \$0 'n1 n2 n3 n4 n5'\n"; exit 1 } my \$CHECK = "OK"; my \$CRONTAB = \$ARGV; chomp(\$CRONTAB); my @ELEM = split(' ',\$ARGV); if (\$#ELEM+1 != 5) { print "a crontab schedule must have 5 elements separated by spaces or tabs\n"; exit 2; } foreach my \$CRON_ENTRY (@ELEM) { if (\$CRON_ENTRY !~ /^(\*|[0-9]{1,2}|[0-9]{1,2}(,[0-9]{1,2})+|[0-9]{1,2}(-[0-9]{1,2})+)\$/) { \$CHECK = "FAIL"; } } if (\$CHECK eq "OK") { print "\$CHECK\n"; exit 0 } else { print "\$CHECK\n"; exit 3 }
Code: move.l #'PROP',d1 move.l #'HETS',d2 move.l #' AG-',d3 move.l #'-WE ',d4 move.l #'FUCK',d5 move.l #' CRU',d6 move.l #'SH--',d7
Code:mov [bp+4],cx
Code: sub.l #\$30061973,(a0)+

Always interesting which secrets a single line of code can reveal. :)
Code: } } } } } } } } }
code tag, you had one job.
Code: private IStuffType _stuff; [CanBeNull] public IStuffType Stuff { get { return _stuff; } set { if (_stuff!= null) { _stuff.ShitHappened -= StuffOnShitHappened; } _stuff= value; if (_stuff!= null) { _stuff.ShitHappened += StuffOnShitHappened; } RefreshShit(); } }

All day everyday..