Real.

The Real type represents an 8 byte double precision floating point value.

Type Specification.

Details of the type and the supported operators:

Category |
Description |
Default |

Value range approx.: -1.79E+308 to +1.79E+308. |
0.0 |

Category |
Operators |

Primary |
x.y foo(x) |

Unary |
+ - |

Multiplicative |
* / mod div |

Additive |
+ - |

Relational |
< > <= >= |

Equality |
== <> |

Assignment |
:= += -= *= /= |

Expressions containing a mix of integers and reals can seamlessly be handled for most situations by evaluating integers as reals where appropriate.

However, a few situations need special attention:

- Function parameters must receive arguments with the correct type due to function overload signature requirements.
- Constants used for division should be written with a decimal as a hint to ensure the compiler doesn't try to perform an integer division.

Example:

Real r := 1.0E+3, q := 300, res;

res := r div q; //Now res == 3.0;

res := r mod q; //Now res == 1.0E+2;

res := 2 + 3/4; //Error at runtime: Value is not an integer

res := 2 + 3/4.0; //This will work!

The Real type supports approximately 15 digits of precision. It allows the smallest positive normal value to be approx. 2.23E-308 (and subnormal approx. 4.95E-324). When working with floating point variables in SCRAMBLECODE (and other languages as well) please be aware:

- The decimal to binary conversion may not be exact.
- Computations may introduce small inaccuracies which can accumulate into noticeable errors. Due to this the order of the involved operations matters.
- When two variables are evaluated for equality, their binary representation may not be the same, but if their values are close within a very small tolerance (for example their difference is 10-12 smaller than their value), they are perceived as being approximately equal.

Standard Functions.

This chapter contains descriptions on the next pages of all the standard functions recognized by the compiler as member-functions of the Real type.