switch (count % 8) {
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
case 4: *to = *from++;
case 3: *to = *from++;
case 2: *to = *from++;
case 1: *to = *from++;
} while ((count -= 8) > 0);
}More http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
Selamat datang. Blog ini mengandungi penulisan dan bahan rujukan berkaitan pengaturcaraan dan penyelidikan yang ingin saya kongsi dengan anda. Semoga bermanfaat. (Nota: Selain teks rumi, blog ini turut mengandungi teks jawi bahasa Melayu)
Tuesday, July 07, 2009
Duff's Device
It looks like an invalid code, but it is valid! This code portion is known as Duff's device.
Monday, June 01, 2009
Thursday, May 28, 2009
Tuesday, March 31, 2009
Modulo a negative number
I'm quite surprised to found that MOD with -ve dividend number is NOT THE SAME as MOD with +ve dividend number.
For +ve dividend number, x MOD n means = x - (floor(x/n) * n)
But for -ve dividend number, x MOD n means =
Example:
but if x = -11, n = 3
or
but, what if -11 MOD -3?
Hmmm...
Links:
http://en.wikipedia.org/wiki/Modulo_operation
p/s: if u still wondering what is 'dividend' : if a/b = c, a is dividend, b is divisor and c is quotient.
What is modulo (MOD)?
It's a operation/function which returns the remainder of a division by two integers. It's like division, except it returns the remainder. E.g. 9/4=2.25, 9 MOD 4 = 1 (since 2x4+1=9).
For +ve dividend number, x MOD n means = x - (floor(x/n) * n)
But for -ve dividend number, x MOD n means =
- x + ( floor(-x/n)+1 ) * n, or
- -(-x MOD n) + n
Example:
x = 11, n = 3
11 MOD 3, use x - (floor(x/n) * n);
= 11 - ( floor(11/3) * 3)
= 11 - (3 * 3)
= 2
but if x = -11, n = 3
-11 MOD 3, use x + ( floor(-x/n)+1 ) * n;
= -11 + ( floor(11/3) + 1) * 3
= -11 + (3 + 1) * 3
= -11 + 12
= 1
or
-11 MOD 3, use -(-x MOD n) + n
= -(-(-11) MOD 3) + 3
= -(11 MOD 3) + 3
= -2 + 3
= 1
but, what if -11 MOD -3?
Hmmm...
Links:
http://en.wikipedia.org/wiki/Modulo_operation
p/s: if u still wondering what is 'dividend' : if a/b = c, a is dividend, b is divisor and c is quotient.
Subscribe to:
Posts (Atom)
-
Sumber : PRPM DBP - Kamus Dewan Edisi Empat Muat turun - (Komp) tindakan memindahkan fail dr stesen komputer utama ke stesen komputer pe...
-
Saya ni bukanlah pakar sangat dalam penyelidikan. Tapi saya ada la sikit ilmu dan pengalaman yang boleh saya kongsikan berkaitan hal ini....