Saturday, May 02, 2009

CS Assignment 1 started

I had been slacking around for so much that I decide its time to start on my assignment due next saturday.I finished up the dlx 4 remainding assembly questions for exercise 1(I did 1 on thursday) before proceeding to write a java application for calculating the mod function.This is to assist me in the writing of my dlx coding later.I have to do all these without using divide or the mod function :( Good thing is , after lots of trial and error , I am done and I can start tomorrow !

The function mod_div(p,q) does two calculations. It performs an integer division p / q, and returns the result.
It performs a modulus calculation, ie it returns the remainder of p / q

So for example: -
mod_div (2, 7) returns 0 for the division and 2 for the remainder
mod_div (7, 2) returns 3 for the division and 1 for the remainder
mod_div (-13, 2) returns -6 for the division and -1 for the remainder
mod_div (13, -5) returns -2 for the division and 3 for the remainder
mod_div (-11, -3) returns 3 for the division and -2 for the remainder
mod_div (5, 0) halts the program

Posted by Ern at 3:01 AM