[Oberon] Simple REAL output (was: can't find obnc-compile)

Chris Burrows chris at cfbsoftware.com
Sun Apr 11 06:39:16 CEST 2021

> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of Duke
> Normandin
> Sent: Saturday, 10 April 2021 11:54 PM
> To: Oberon
> Subject: [Oberon] obnc can't find obnc-compile
> Could not figure out how to output real numbers in human-readable format
> using the vishaps compiler. So I installed obnc.

If the Oberon library you are using doesn't include a procedure to output
real numbers exactly the way you want them to appear in your example it is
quite feasible to do this yourself using library procedures that do exist.
This would be an ideal introductory exercise for you to try. For example,
follow these steps if you want to output a real number with 1 decimal place
e.g. 98.6 

1. Use the Oberon ENTIER function to get the whole part of the real number
as an integer (= 98).
2. Subtract the result you got in (1) from the real number to get the
fractional part (= 0.6).
3. Get the first digit of the fractional part by multiplying it by 10.0 (=
6.0) and use ENTIER to discard any other digits (= 6).

Output the result you got in (1) using Out.Int:  "98"
Output the decimal point using Out.Char:         "98."
Output the result you got in (3) using Out.Int:  "98.6"


Chris Burrows
CFB Software

More information about the Oberon mailing list