Re: Win32Forth & negative zero



Andrew Haley wrote:
> Ed <nospam@xxxxxxxxxxx> wrote:
>
>
>>"Andrew Haley" <andrew29@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>>news:11dusvj8dif3mf0@xxxxxxxxxxxxxxxxxxxxx
>>
>>>Ed <nospam@xxxxxxxxxxx> wrote:
>>>[...]
>>>>There is (apparently) no "best" rounding method.  When asked which
>>>>method should be used, the people at the "Dr Math" website would
>>>>simply say "it depends" [on your intended application].
>>>
>>>There has to be some kind of default, and round to nearest or even is
>>>a good choice for that.
>
>
>>Round to nearest/even is not necessarily better than others.
>
>
> It's better _overall_ than most other approaches.  Some applications
> might want something else, which is fine.

Just to pick a nit, it's not quite right to call round to
nearest with even tie breakers "IEEE rounding", because IEEE-754
(1985) has four rounding modes, labeled in C99 as FE_TONEAREST,
FE_DOWNWARD, FE_UPWARD, and FE_TOWARDZERO.

>>>>In a recent c.l.f. post (to which there was no response) I suggested
>>>>the requirement that ANS Forth systems *must* use IEEE rounding was
>>>>inappropriate and should be eliminated.  That "round to nearest"
>>>>should be left to the implementor to decide - just as in other
>>>>languages.

I actually meant to respond to this, but stuff intervened.  I
agree with Ed that the ANS Forth wording is contradictory, and
needs revision.  I think it needs some caveats that apply when
and only when an implementation follows IEEE-754.  I agree that
it ought not to mandate IEEE-754, but I think it should strongly
encourage it.

>>>Other languages, in particular C and C++, are moving towards IEEE, and
>>>it would be untimely or Forth to move away.

In particular C99, which I think is getting it right, and ought
to be emulated.  And no, I am not a person who especially likes C.

>>Is it the "languages" or the "compilers" that are moving to IEEE?
>>Surely only the latter!
>
>
> The former, in fact.

That's my impression of C99.  Although it does not mandate
IEEE-754, that's its very strong flavor.  For example, its
library includes the extra functions that IEEE-754 recommends,
including rounding mode control functions and access to the
floating-point exception environment, and functions like
copysign(), nextafter(), etc.

-- David
.



Relevant Pages

  • Re: Fastcode RoundTo
    ... The rounding control could be like the following: ... {Round to nearest else to even digit. ... drHalfOdd, {Round to nearest else to odd digit. ...
    (borland.public.delphi.language.basm)
  • Re: Hillary Clinton Gives Driving Advice
    ... would have to do would be to round to the nearest $0.1 instead. ... The gov't has tried that on the one with issuing the dollar coin (the ... "When you can't afford the gas to drive to the job ...
    (rec.autos.driving)
  • Re: Burette/Thermom. Readings - Rounding?
    ... >I realised I don't know how to round values from thermometers, burettes ... then you round DOWN to 20.00; else if it is above the halfway ... >to the upper or lower regions inbetween the divisions. ... You have decided to read to the nearest 5 in the last ...
    (sci.chem)
  • RE: Rounding to nearest .00 or .50
    ... Then set your textbox control source and/or calculated query field to the ... > a course by dividing the total number of minutes of course instruction by 60 ... > but I need it to round to the nearest .00 which, ...
    (microsoft.public.access.forms)
  • Re: Integer arithmetic problem
    ... So then whether you round up to -1 or down to -2 is left to ... round down as Tcl does. ... In C < C99 it was not defined what the answer would be (it was ... As to why rounding towards zero or down would be better I don't know, ...
    (comp.lang.tcl)