swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
    Related Concepts  
operator  

+ (plus)

 
 

Return type: Integer
Returns:       The sum of two numeric expressions.

Syntax

numeric-expression + numeric-expression


Purpose

You can add two numeric values together using the + operator.

To add BCD numbers, you must import the ombcd.xmd file in your program. To add floating point numbers, import the omfloat.xmd file.

You can add values of mixed data types (for example, BCD numbers and integers) as long as you follow the rules listed in Operations with mixed data types.

Always surround arithmetic operators with spaces.

BCD Example:

  ; Exact Total = Dollars + Cents
     import "ombcd.xmd" unprefixed
    process
        local bcd dollar-amount initial {295}
        local bcd cents-amount initial {0.22}
        local bcd exact-total
        set exact-total to dollar-amount + cents-amount
        output "Exact total is "
             || "<$,NNZ.ZZ>" % exact-total
             || "%n"
        ; Output: 'Exact total is $295.22'.

Floating Point Example:

  ; Find the total of the radii of the earth, the moon, and the sun.
    import "omfloat.xmd" unprefixed
    process
        local float earth-radius initial {6.371 * float 10 ** 106}
        local float moon-radius initial {1.7383 * float 10 ** 106}
        local float sun-radius initial {6.9596 * float 10 ** 108}
        local float total-radii
        set total-radii to earth-radius  + moon-radius + sun-radius
        output "Total of celestial radii is " || "10fed" % total-radii  || " meters.%n"
        ; Output: "Total of celestial radii is 7.0407e+108 meters."

Mixed Data Type Example:

  ; The cashier counts the dollars and totals the value of the coins.
  ; Find the grand total of the dollars counted and the coins totaled.
     import "ombcd.xmd" unprefixed
    process
        local integer dollar-count initial {295}
        local bcd coin-total initial {38.78}
        local bcd GrandTotal
        set GrandTotal to dollar-count + coin-total
        output "Grand total is $" || "d" % GrandTotal  || "%n"
        ; Output: 'Grand total is $333.78'.

The word plus is a deprecated synonym for +.

For floating point numbers, overflow and underflow values return infinity and zero, respectively.

BCD numbers cannot overflow, but underflow returns 0.

For integers, underflow returns zero, but overflow returns an incorrect answer that depends on the operating system.

      Related Concepts
 
 

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

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:51:21 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.