[Oberon] CHAR to/from BYTE conversion

Srinivas Nayak sinu.nayak2001 at gmail.com
Sat Jul 9 14:32:58 CEST 2016


Exactly.
C and C++ together have spread a severe mental disease.
Now I am trying to unlearn things,
which now seems very very difficult.

:-(

Surprised to discover yesterday that:

"The >> operator in C and C++ is an arithmetic shift if used with a signed integer type.
If it is used on an unsigned integer type instead, it will be a logical shift."

"The (1999) ISO standard for the programming language C defines the right shift operator in terms of divisions by powers of 2.
Because of the above-stated non-equivalence, the standard explicitly excludes from that definition the right shifts of signed numbers that have negative values. It doesn't specify the behaviour of the right shift operator in such circumstances,
but instead requires each individual C compiler to define the behaviour of shifting negative values right."

Now I am comparing and contrast semantics of C's division / and %,
to that of Oberon's DIV and MOD. And how they are related to Shifts.
What happens when division and modulus' operands are
combinations of positive and negative numbers...

:-(


With thanks and best regards,

Yours sincerely,
Srinivas Nayak

Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.in/

On 07/08/2016 11:14 PM, Paul Reed wrote:
> Hi Srinivas,
>
>> That means both CHAR and BYTE holds values 0 to 255.
>
> No, CHAR holds characters, 0X to 0FFX, including "A", "B" etc.; and BYTE
> holds 0 to 255, a sub-range of the INTEGER range.
>
> Your statement is indicative of how much damage C has done to the world :)
>
> Cheers,
> Paul
>
>
> --
> 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