No subject


Mon Sep 26 12:33:25 CEST 2005


"
Note:
(-5) DIV 3 = -2
but
-5 DIV 3 = -(5 DIV 3) = -1
"

The language wants
x = (x DIV y) * y + (x MOD y)

-Doug

Stefan Salewski wrote:
> 
> Hello,
> 
> I think there is something wrong with the DIV statement.
> 
> ==========
> 
> MODULE StSTest;
> 
> IMPORT Out;
> 
> PROCEDURE Do*;
> VAR
>   i,j,k:LONGINT;
> BEGIN
>   Out.String("Output is:");
>   Out.Ln;
>   i:=10;
>   j:=3;
>   k:=-(-i DIV j);
>   Out.Int(k,8); Out.Ln;
>   i:=-i;
>   k:=-(i DIV j);
>   Out.Int(k,8); Out.Ln;
> END Do;
> 
> BEGIN
> END StSTest.
> 
> StSTest.Do ~
> 
> Output is:
>        3
>        4
> ==========
> 
> Best regards
> 
>   Stefan Salewski
> --
> Oberon at inf.ethz.ch mailing list for ETH Oberon and related systems
> http://www.lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list