From: Kurt Baty (kurt@wsfdb.wsfdb.com)
Date: Mon May 05 2003 - 14:01:56 PDT
Precedence: bulk
> >
> > > I had figured the results
> > >
> > > 2 ** -1 = 1
> > > -2 ** -1 = -1
> > >
> > > were a result of rounding to nearest.
> > >
> >
> > Actually, this rounding is not "round nearest"
> > this is "round up" (I say "round away-from-zero"
> > so as to not be confused in negative numbers).
> > 0.5 would round to 0 in "round nearest".
>
> Then I'm confused. If the rounding was "away from zero",
> then wouldn't all of the combinations whose real result
> is in the range (0.0,1.0) round to an integer result of 1,
> and likewise results in the range (-1.0,0.0) would round to
> a integer result of -1? Your test program results don't
> indicate this.
some functions:
truncate -> real result in the range (0.0 <= fract < 1.0)
goes to 0
ceiling -> real result in the range (0.0 < fract <= 1.0)
goes to 1
round -> real result in the range (0.0 < fract < 0.50)
goes to 0
real result in the range (0.5 < fract <= 1.0)
goes to 1
real result is exactly (fract = 0.5)
case(rounding mode)
up: goes to 1 (round "away from zero")
down: goes to 0 (round "towards zero")
nearest: if(low bit of abs(integer) part is:
zero: goes to 0
one: goes to 1
does this help?
>
> In case it isn't already obvious, I am not a floating point
> expert.
I must be.
>
> > > But, my specific question is, are these the results you are
> > > advocating for these particular operands?
> >
> > yes, to took x ** y where x,y are integers and converted
> > x (integer -> real -> bits(ieee 64 floating point))
> >
> > did a x_bits ** y using the pow function
> >
> > function [63:0] pow; // l**r, where l is fp64 and r is integer
> >
> > converted answer_bits (bits(ieee 64 floating point) -> real -> integer)
> >
> > and I make the claim that this is the most "math correct answer".
>
> If you applied this methodology to integer division, what result would
> you get for 1 / 2?
>
if the real typed, answer = 0.5
and verilog converts real to integer by rounding then, 1
if integer division is truncated by definition then
integer = truncate(real typed, answer) then 0
kurt
This archive was generated by hypermail 2.1.4
: Mon May 05 2003 - 14:09:45 PDT
and
sponsored by Boyd Technology, Inc.