| 
 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 abs
| 2008 | 
Submission reference: IN1539
Is there an abs() function/process in occam, as for the life of me I can't find it in the library documentation :).
Oddly enough, no, there is not! Perhaps we should add one just for the sake of completeness? But you can write your own quite easily:
  INT FUNCTION abs (VAL INT v)
    INT r:
    VALOF
      IF
        v < 0
          r := -v
        TRUE
          r := v
      RESULT r
  :
This is an example of an occam-pi function declaration (slides 88..93 of shared-etc). It can be used in the expected way – e.g. "x := abs (i)". Bear in mind that this will cause a run-time error if you were to ask for "abs (MOSTNEG INT)".
Keywords: abs
| 
			This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. |