CO538 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 inverting
2000 |
In a post, Fred says that the maximum negative 32 bit int is -2147483648, so I have coded appropriately ...
-- ensure seed is positive & legal IF seed = (-2147483648) <---------ERROR!!! seed := 2147483647 seed < 0 seed := -seed seed = 0 seed := 1 TRUE SKIP
But I get an error on the line arrowed above which says:
Overflow when evaluating constant expresssion
Help!! Have I done something wrong or is the info on cs2 wrong?
The compiler treats -2147483648 as an expression, so it gets an error when trying to evaluate 2147483648 (which is larger than the largest INT). If it got past that, it would get another error trying to negate it.
occam has a special way of naming the largest and smallest of any of its number types. For example,
MOSTNEG INT MOSTPOS INT
give you, respectively, the most negative and positive integers. Other ways we can write MOSTNEG INT are:
#80000000 1 << 31
But ... my colleague, David Wood, suggests you might like to consider:
TIMER tim: INT seed: SEQ tim ? seed seed := (seed >> 2) + 1
Keywords: inverting , int , random , q7
Referrers: Question 29 (2002)
I am currently doing the pairs toggling bit of Q4. I am trying to say
IF there is a toggle input THEN switched := NOT switched ELSE carry on excuting the rest of the code.
where toggle is an input channel and switched is a boolean variable.
You are describing a poll on the toggle channel. See slide 5-37 in the notes. You may consider the use of polling absolutely essential (see the comment on slide 5-37) for your solution to this part of the question - even though it's not!
Referrers: Question 47 (2000)
Is it possible to invert a BOOL variable - for example:
minus = NOT minus
???
Yes - but it should be:
minus := NOT minus
Keywords: inverting
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. |