SF Talk wrote:
>
> Date: Mon, 08 May 2000 08:53:36 -0700
> From: "Rick VanNorman" <rvn_at_forth.com>
> Subject: Re: Binary question
>
> >From: "Michael Kemper" <mikek_at_metretek.com>
> >
> >Rick,
> >I was coding a crc algorithm and ran across this peculiarity. It may be
> >normal operation, but seems inconsistant to me:
> >
> >If I do the following
> >$CEE1289A $100 / h.
> >>$FFCEE129
> >
> >but if I perform the following:
> >$CEE1289A 2/ 2/ 2/ 2/ 2/ 2/ 2/ 2/ h.
> >>$FFCEE128
> >which is what I'd expect from both versions. Both versions bring the sign
> >bit into the result, but the first rounds the result, which I wouldn't
> >expect from the standard "/" word. Is this normal?
>
> Mike,
>
> My expectations are the same as yours, and I was very surprised to find
> the results you cite. Here is the quote straight from Intel's pentium
> instruction reference for the IDIV instruction:
>
> <quote>
>
> Non-integral results are truncated (chopped) towards 0. The sign of
> the remainder is always the same as the sign of the dividend.
> The absolute value of the remainder is always less than the
> absolute value of the divisor. Overflow is indicated with
> the #DE (divide error) exception rather than with the OF (overflow) flag.
>
> </quote>
>
> I use the IDIV instruction in / so it will (should) behave like this.
> Consider if the "truncated (chopped) towards 0" is implemented in
> hardware without consideration for the sign bit. This would produce
> the exact result we are seeing.
>
> I don't know what the correct answer is. Can anyone run this on
> another 32-bit Forth and report the results?
>
> Thanks,
>
> Rick
>
Rick,
Is there no option to choose symmetric or truncating division? I thought
I remembered that there is.
Jerry
.
Received on Mon May 08 2000 - 13:44:43 PDT
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 09-Feb-2012. Archive updated nightly.