*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

colsetname =real[withreal-exp1..real-exp2];

### Order

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.

## Operations

: negation of the integer value**~**r`r`

`r1`

: addition**+**r2`r1`

: subtraction**-**ri2`r1`

: multiplication*****ri2`r1`

: division**/**r2

: returns true if and only if neither**Real.==**(r1,r2)`r1`

nor`r2`

is NaN, and`r1`

and`r2`

are equal

: absolute value of**abs**r`r`

: return largest integer not larger than**floor**r`r`

: return smallest integer not less than**ceil**r`r`

: round**trunc**r`r`

towards zero

: return integer nearest to**round**r`r`

: convert integer**real**i`i`

to real value

: minimum of**Real.min**(r1,r2)`r1`

and`r2`

: maximum of**Real.max**(r1,r2)`r1`

and`r2`

r: square root of**Math.sqrt**`r`

r: natural logarithm**Math.ln**

r: exponential**Math.exp**

r: sine**Math.sin**

r: cosine**Math.cos**

r: tangent**Math.tan**

: arc tangent**Math.arctan**r

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.

You must be logged in to post a comment.