In the IEEE standard, rounding results of floating-point computations
needs to be done by roundTiesToEven by default. However, for rounding
floats to integers it merely describes five different functions (one
for each commonly-used rounding method), and has no opinion on which
you should use.

I think our choice is better for general programming. Say you index an
array using the expression `A[round(x + i)]`, where i is consecutive
integers, and x is a fraction between 0 and 1. Clearly, this will
touch all array elements. But with rounding ties to even, you
*usually* get that behavior, except when x==0.5, and then you'd only
get even-index elements. That seems crazy to me.


On Wed, Jun 4, 2014 at 8:41 PM, Stefan Karpinski <[email protected]> wrote:
> It could, but it shouldn't. The rounding mode and how you round to integers
> are completely different matters.
>
>
> On Wed, Jun 4, 2014 at 8:16 PM, Kevin Squire <[email protected]> wrote:
>>
>> Couldn't this be provided by the get_rounding/set_rounding/with_rounding
>> framework?
>>
>>
>> On Wed, Jun 4, 2014 at 2:59 PM, Stefan Karpinski <[email protected]>
>> wrote:
>>>
>>> This isn't really related to IEEE rounding modes. Floating-point rounding
>>> modes are about choosing which of the closest representable floating-point
>>> values an operation should produce when the true value is between them. The
>>> round function is a well-defined mathematical function regardless of IEEE
>>> rounding mode. The man page for the libc round function says:
>>>
>>>> The round() functions return the integral value nearest to x rounding
>>>> halfway cases away from zero, regardless of the current rounding direction.
>>>
>>>
>>>
>>>
>>> On Wed, Jun 4, 2014 at 5:51 PM, John Myles White
>>> <[email protected]> wrote:
>>>>
>>>> One question: I have the impression that the round() function is not
>>>> affected by the currently chosen rounding rule in Julia. Is that right?
>>>>
>>>>  -- John
>>>>
>>>> On Jun 4, 2014, at 2:48 PM, Stefan Karpinski <[email protected]>
>>>> wrote:
>>>>
>>>> > We follow C, Fortran, Matlab, Python and most other programming
>>>> > languages here. R and NumPy's rule is pretty unusual; it has some nice
>>>> > statistical properties (it's apparently known as "statistician's 
>>>> > rounding"),
>>>> > but is quite awkward for general programming tasks.
>>>>
>>>
>>
>

Reply via email to