CO631 Anonymous Questions and Answers Keyword Index |
This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.
To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.
Keyword reference for negative-numbers
2003 |
Could you tell me why the following cose is outputting negative numbers?
[snip code]
I really dont understand what's wrong with it!
See the answer to Question 24 (2003). That should explain it.
Keywords: negative-numbers
How is it possible that If I run the process (without inputting anything) at a certain point I start getting negative numbers for the 2nd and 3rd column ?
This is quite possibly normal behaviour. In standard 32-bit 2's complement signed arithmetic:
1500000000 PLUS 1500000000 = -1294967296
In occam, you must use the `PLUS' operator to get this behaviour. The standard `+' operator will cause a run-time error when this happens, which is generally what you want.
You might want to consider slowing the output down with a suitable delay. See Question 13 (2000) for how to do this. In relation to Q4, the initial values output by the program should be correct, until something overflows that is. If the output goes negative very early on, then something is probably wrong -- check the values!
Keywords: overflow , negative-numbers
Referrers: Question 26 (2003)
2000 |
In the specification for the p bit in q4.occ, it says: "take the output arriving from the tail from that arriving directly from the delta". I'm certain, well confident, well satisfied, ... ERM.. at least I think I've implemented it as specified, but my output gives:
-1 -2 -3 -4 ...
I am very tempted just to switch the channels going into plus so that it gives:
1 2 3 4 ...
when its in subtractor mode. Or are the negative numbers actually what's required ... i.e. the assignment means do as I say not do what you think I mean ... ?
You've got me here! In question 4 on the exercise sheet, it doesn't attempt to specify which way around the minusing should operate (in response to a p from the keyboard). So, doing it either way round would be OK.
In the q4.occ file, I tried to make this precise but - given the complexities of natural language - managed to say it the wrong way around :-( ... Apologies for this. So, doing it either way round - what I said or what I meant - is OK.
Keywords: q4 , negative-numbers
Last modified Mon May 15 17:39:46 2006
|