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)
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.
Wednesday, February 04, 2009
RA / Programmer wanted!
Great news.
For those who is very (yes, VERY) interested in Bioinformatics and research, and interested in:
- pursuing Master or PhD, or
- doing programming, or
- being a research assistant, or
- gaining experience in research, then
You may qualified for this job!
RA is wanted.
Pls contact Dr. Mohd Firdaus Raih (firdaus [at] mfrlab.org) by forwarding your CV. You may visit the research group website. More vacancies
p/s: I used to work there (before i join UPM), and gained a great experience. See my name in the publication section!
Subscribe to:
Posts (Atom)