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

modulo

 
 

Return type: Integer
Returns:       The remainder.

Syntax

numeric-expression modulo numeric-expression


Purpose

Use modulo to find the modulus of a number with respect to a base value. The modulus is the remainder from dividing the number by the base value.

To use BCD numbers in a modulo operation, you must import the ombcd.xmd file in your program. To use floating point numbers, import the omfloat.xmd file.

You can use 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.

Integer example:

  process
     local integer seconds initial {3700}
     local integer minutes
     local integer hours
     local integer days
     
     set minutes to seconds / 60
     set seconds to seconds modulo 60
     set hours to minutes / 60
     set minutes to minutes modulo 60
     set days to hours / 24
     set hours to minutes modulo 24
     output "Days: "
         || "d" % days
         || "; Hours: "
         || "d" % hours
         || "; Minutes: "
         || "d" % minutes
         || "; Seconds: "
         || "d" % seconds
         || "%n"
  ; Output: "Days: 0; Hours: 1; Minutes: 1; Seconds: 40"

Mixed data type example:

  import "ombcd.xmd" unprefixed
  process
     local bcd seconds initial {3700}
     local bcd minutes
     local bcd hours
     local bcd days
     
     set minutes to truncate (seconds / 60)
     set seconds to seconds modulo 60
     set hours to truncate (minutes / 60)
     set minutes to minutes modulo 60
     set days to truncate (hours / 24)
     set hours to minutes modulo 24
     output "Days: "
         || "d" % days
         || "; Hours: "
         || "d" % hours
         || "; Minutes: "
         || "d" % minutes
         || "; Seconds: "
         || "d" % seconds
         || "%n"
  ; Output: "Days: 0; Hours: 1; Minutes: 1; Seconds: 40"

      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.