swirl Guide to OmniMark 5   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesOMX VariablesErrors
 
     
operator   - (negate)    

Syntax

  (- | negate) numeric-expression


Purpose

Use - to change the sign of any numeric-expression. If the numeric-expression is positive, then the result is negative. If applied to a negative expression, the value becomes positive.

You use - as a unary operator (an operator with only one argument), to reverse the sign of a numeric expression.

Note: There should not be a space between the unary - and its argument:

If you negate the value of a BCD number, you must have included "ombcd.xin" in your program. If you negate the value of a floating point number, you must have included "omfloat.xin" in your program. For BCD and floating point numbers, overflow and underflow values will return infinity and zero, respectively.

  process
      local integer foo initial {9}
      local integer bar initial {7}

      output "Calculating ' - (9 + -7)' = "
          || "d" % - (foo + -bar)
          || "%n"
  ; displays "Calculating ' - (9 + -7)' = -2"

This does not change the absolute value of the numeric-expression.

Use the punctuative form ( -) rather than the keyword negate.

Usage examples:

  -432
  -("4987" + 315 * 12)
  - "3" > "04"
  negate "3" > "04"

BCD example:

  include "ombcd.xin"
  process
     local bcd foo initial {23}
     local bcd bar
     set bar to -foo
     output "foo = "
              || "d" % foo
              || "%n"
     output "bar = "
              || "d" % bar
              || "%n"
  ; Output: foo = 23
  ;         bar = -23

       
----  

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ OMX ] [ OMX ] [ ERRORS ]

Generated: August 11, 2000 at 3:06:56 pm
If you have any comments about this section of the documentation, send email to docerrors@omnimark.com

Copyright © OmniMark Technologies Corporation, 1988-2000.