swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax   Related Concepts  
operator  

* (times)

 

 

Return type: Integer
Returns:       

The product of its operands.



Syntax
  numeric-expression * numeric-expression


Purpose

You can multiply two numeric values together using the * operator.

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

You can multiply 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:

  ; Distance = speed * time
     import "ombcd.xmd" unprefixed
    process
        local bcd kilometers-per-hour initial {90}
        local bcd hours initial {1.5}
        local bcd distance
        set distance to kilometers-per-hour * hours
        output "Distance is "
            || "d" % distance
            || " kilometers.%n"
  ; Output: 'Distance is 135 kilometers'.

Floating Point Example:

  ; E = IR (volts = amperes * ohms)
    import "omfloat.xmd" unprefixed
    process
        local float amperes initial {1.9237}
        local float ohms initial {60}
        local float volts
        set volts to amperes * ohms
        output "Volts = "
            || "d" % volts
            || "%n"
  ; Output: 'Volts = 115.422'

Mixed Data Type Example:

  import "ombcd.xmd" unprefixed
  process
      local integer apples-per-child initial {6}
      local integer school-children initial {28}
      local integer total-apples

      local bcd apple-price
      local bcd tax-rate
      local bcd total-price

      set total-apples to apples-per-child * school-children
      output "Total apples = "
                  || "d" % total-apples
                  || "%n"

      set apple-price to 0.33
      set tax-rate to 0.05
      set total-price to total-apples * apple-price * (1 + tax-rate)
      output "Total price = "
                  || "<$,NNZ.ZZ>" % total-price
                  || "%n"
  ; Output: 'Total apples = 168'
  ;          'Total price = $58.21'

The word times is a deprecated synonym for *.

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

BCD numbers cannot overflow, but returns 0 on underflow.

Integers cannot underflow, but overflow returns an incorrect answer depending on the operating system.

    Related Syntax
   / (divide)
 
Related Concepts
   int32 data type
 
 

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

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:44:54 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.