|
I think by "undefined" they just mean that it's defined differently in the C
preprocessor depending on what's available to the system -- which means that
the manual can't afford to describe a definitive behavior. The behavior you
describe in OSX sounds like the "banker's round," which is superior to the
floor rounder if you are doing processing that for one reason or another has
a lot of x.5 values, since it cancels the upward bias.
Jacob Joaquin wrote:
>
> While we're on the subject I came across this line in the manual, and
> found it somewhat unsatisfactory, "The integer value nearest to x ; if
> the fractional part of x is exactly 0.5, the direction of rounding is
> undefined."
>
> Shouldn't a function like this have a clearly defined behavior?
>
> On OS X, round(0.5) produces 0, while round(1.5) produces 2. I pretty
> much stay away from round, and prefer going with either int(ifoo +
> 0.5) or floor(ifoo + 0.5).
>
> Best,
> Jake
> --
> The Csound Blog - http://csound.noisepages.com/
>
>
> On Fri, Dec 11, 2009 at 8:37 AM, Matt Barber wrote:
>> Hello,
>>
>> I am trying to find out what kind of rounding the round() opcode does.
>> I've been going through the csound code, and I want to make sure I'm
>> understanding it correctly:
>>
>> It seems as though the type of rounding is system-dependent, but that
>> if lrint() or lrintf() is defined in the c library it is used? Does
>> anyone know if lrint rounds 0.5 to the nearest even number (so called
>> "banker's round") by default? I notice some of the provided functions
>> to be used in place of lrint round 0.5 away from zero. I am assuming
>> that on most linux distros that lrint()/lrintf() will be used and that
>> it will round 0.5 to nearest even, but I wanted to check this with the
>> list... I suppose I could just create a diagnostic orc/score to find
>> out what it's doing on my system, but I might need to open my project
>> in another linux distro soon and I don't want to go in with poor
>> assumptions.
>>
>>
>> Thanks,
>>
>> Matt
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
--
View this message in context: http://old.nabble.com/rounding-tp26747459p26748426.html
Sent from the Csound - General mailing list archive at Nabble.com.
Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |