[Oberon] CHAR to/from BYTE conversion

Jörg joerg.straube at iaeth.ch
Wed Jul 6 16:53:53 CEST 2016


Hi Srinivas

Let's assume you have three variables
 VAR
   c: CHAR;
   b: BYTE;
   i: INTEGER;

If you write c := CHR(b), it internally works as if you wrote i := b; c :=
CHR(i);
If you write b := ORD(c), it internally works as if you wrote i := ORD(c); b
:= i;

The difference of BYTE and CHAR is the type;
with BYTE you can do calculations, with CHAR you cannot. CHAR hold ASCII
characters.

Jörg

-----Original Message-----
From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of Srinivas
Nayak
Sent: Mittwoch, 6. Juli 2016 16:00
To: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Subject: [Oberon] CHAR to/from BYTE conversion

We have ORD() and CHR().
ORD() converts CHAR to INTEGER.
CHR() converts INTEGER to CHAR.

How to convert BYTE to/from CHAR ?

Can a CHAR byte hold -ve values? Seems not...
BYTE also represents values from 0 to 255.
Then what is the difference between BYTE and CHAR?

We say, BYTE and INTEGER are compatible;
If we assign -12 to a BYTE, what will happen?

Kindly help me understanding these.


With thanks and best regards,

Yours sincerely,
Srinivas Nayak

Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.in/
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list