Page 1 of 1

Round() Differs in AROS and OS3 Versions

Posted: Wed Mar 22, 2023 6:31 pm
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)) 

Re: Round() Differs in AROS and OS3 Versions

Posted: Wed Mar 22, 2023 6:56 pm
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. "

Re: Round() Differs in AROS and OS3 Versions

Posted: Wed Mar 22, 2023 7:56 pm
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

Re: Round() Differs in AROS and OS3 Versions

Posted: Sat Mar 25, 2023 9:01 pm
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.

Re: Round() Differs in AROS and OS3 Versions

Posted: Mon Mar 27, 2023 6:22 pm
by NathanH
Thanks!

Re: Round() Differs in AROS and OS3 Versions

Posted: Mon Mar 27, 2023 7:41 pm
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.

Re: Round() Differs in AROS and OS3 Versions

Posted: Thu Apr 13, 2023 3:10 pm
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.

Re: Round() Differs in AROS and OS3 Versions

Posted: Wed Jul 24, 2024 9:57 pm
by airsoftsoftwair

Code: Select all

- Fix [OS3/Non-FPU]: Round()'s result wasn't always consistent with the behaviour on all other platforms