NOTE: This type is introduced in CPN Tools 3.5.5.

Real numbers are distinguished from integers by the decimal point. The period separates the integer part from the fractional part. One or more digits must follow after the decimal point. The real color set is large.

IMPORTANT: Reals are NOT equality types in Standard ML. In the CPN ML variant used in CPN Tools this has been modified, meaning you should be able to use reals as any other type, but beware that equality is still dodgy because of rounding errors. We recommend against relying on exact comparisons, and instead use only inequalities using reals (expressions like x < 1.1). While reals work with the state space tool, we recommend against using reals with state space analysis.

For now, reals are considered experimental due to the very fundamental changes needed to make them work; we welcome any error reports regarding reals, but do not otherwise provide any support for this type before the release of 4.0.

Declaration Syntax

colset name = real [with real-exp1..real-exp2];


usual ordering of numbers

Optional with Clause

Restricts the real color set to an interval determined by the two expressions real-exp1 and real-exp2. It must be the case that real-exp1<=real-exp2.

Declaration Examples

color R = real;

color SomeReal = real with 1.0..3.5;

var someReal : SomeReal;

The CPN variable someReal may have a range of real values from 1.0 to 3.5. For example, 1.0 and 3.234 are legal values, but 1 and 4.2 are not.


  • ~r: negation of the integer value r
  • r1 + r2: addition
  • r1 - ri2: subtraction
  • r1 * ri2: multiplication
  • r1 / r2: division
  • Real.==(r1,r2): returns true if and only if neither r1 nor r2 is NaN, and r1 and r2 are equal
  • abs r: absolute value of r
  • floor r: return largest integer not larger than r
  • ceil r: return smallest integer not less than r
  • trunc r: round r towards zero
  • round r: return integer nearest to r
  • real i: convert integer i to real value
  • Real.min(r1,r2): minimum of r1 and r2
  • Real.max(r1,r2): maximum of r1 and r2
  • Math.sqrt r: square root of r
  • Math.ln r: natural logarithm
  • Math.exp r: exponential
  • Math.sin r: sine
  • Math.cos r: cosine
  • Math.tan r: tangent
  • Math.arctan r: arc tangent

The trigonometric functions all work in units of radians.

For additional details and functions see the REAL signature and the MATH signature in the SML Basis Library.

See also color set functions.


Subset color sets
Time color sets

You must be logged in to post a comment.