Integers - Connect_CDC - connect_cdc_mimix_share - 5.8

Connect CDC System Reference Guide

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (MIMIX Share)
Version
5.8
Language
English
Product name
Connect CDC
Title
Connect CDC System Reference Guide
Copyright
2024
First publish date
2003
ft:lastEdition
2024-02-12
ft:lastPublication
2024-02-12T15:11:59.486869

If an expression contains a division of an integer by an integer, the result is an integer. See the following examples, where C1 = 1.

Expression

Result Value

C1 + 10/5

3.0

C1 + 10/10

2.0

C1 + 10/9

2.0

C1 + 5/10

1.0

C1 + 6/10

1.0

C1 + 10/3

4.0

C1 + 10.0/3.0

4.33

C1 + 9/10

1.0

C1 + 9.0/10.0

1.90

C1 + todecimal(9)/todecimal(10)

1.90

C1 + rounddecimal(9.0/10.0, 1)

C1 + rounddecimal(9.0/10.0, 5)

This expression includes a second argument that specifies the number of decimal places that should be used when rounding and creating the resulting decimal.

1.9

1.90000

If either the numerator or denominator or both is real/float/decimal, then the result is of that type and retains the fractional part of the result. Thus, 10.0/3 = 3.33333 and 9/10.0 is 0.9. When an integer is added to a decimal, the result is decimal, which is why all the examples include the decimal point.

If you divide integers, then the default behavior is to produce an integer result where the result is "rounded" down to the closest integer.

If you want a precise decimal result, then do one of the following:

  • Recast the integer constant as a decimal. As in the example above, make it a decimal by adding ".0" where the integer "10" can be cast as a decimal by writing it as "10.0": C1 + 9/10 is recoded as C1 + 9.0/10/0.

  • Alternately, you can use the TODECIMAL or ROUNDDECIMAL built-in expression to convert the integer constant or variable to decimal before doing the division.