Round() Differs in AROS and OS3 Versions

Report any Hollywood bugs here
Post Reply
NathanH
Posts: 107
Joined: Sun Jul 05, 2015 1:29 am
Location: Caldwell, Idaho

Round() Differs in AROS and OS3 Versions

Post by NathanH »

Hi,

The following code prints 3155 on Amiga OS3 (correct, I believe) and 3154 on AROS (incorrect, I believe). Regardless, I think you should get the same answer regardless of operating system.

NathanH

Code: Select all

 DebugPrint(Round(3154.5)) 
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Round() Differs in AROS and OS3 Versions

Post by Flinx »

Windows 3154. That is correct I think, because this is Rounding half to even.

By the way, typo in the manual: "This function rounds x to the next intenger. "
NathanH
Posts: 107
Joined: Sun Jul 05, 2015 1:29 am
Location: Caldwell, Idaho

Re: Round() Differs in AROS and OS3 Versions

Post by NathanH »

Interesting, I had never heard of that practice. I was taught in school that .5 always rounds up. But that was back in the 1960's.

NathanH
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Round() Differs in AROS and OS3 Versions

Post by airsoftsoftwair »

Flinx wrote: Wed Mar 22, 2023 6:56 pm By the way, typo in the manual: "This function rounds x to the next intenger. "
Thanks, fixed that.
NathanH wrote: Wed Mar 22, 2023 7:56 pm Interesting, I had never heard of that practice. I was taught in school that .5 always rounds up. But that was back in the 1960's.
There are different rounding rules. Flinx is correct. Round() will use half to even rounding so if a number is exactly between two integers, it will round to the event integer.
NathanH wrote: Wed Mar 22, 2023 6:31 pm The following code prints 3155 on Amiga OS3 (correct, I believe) and 3154 on AROS (incorrect, I believe).
True. It's a bug in the OS3 version. It should be 3154 on OS3 too because that's the even number. Will be fixed.
NathanH
Posts: 107
Joined: Sun Jul 05, 2015 1:29 am
Location: Caldwell, Idaho

Re: Round() Differs in AROS and OS3 Versions

Post by NathanH »

Thanks!
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: Round() Differs in AROS and OS3 Versions

Post by jalih »

I think the most sensible default would be to always round .5 up and add another function to change the rounding mode if needed.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Round() Differs in AROS and OS3 Versions

Post by airsoftsoftwair »

Well, of course I can't change the behaviour of Round() for compatibility reasons but something like SetRoundMode() might indeed make sense. The default round mode could be set to half to even rounding for compatibility then.
Post Reply