Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline bugreportaccount  
#1 Posted : 11 March 2021 02:27:07(UTC)
bugreportaccount

Rank: Newbie

Groups: Registered
Joined: 11/03/2021(UTC)
Posts: 4
New Zealand

With rounding selected as half to even, the rounding doesn't round .5 up to 1.

For example, with decimal places set to 0:
2.50000 = 2
2.50001 = 3

This doesn't seem in line with the expectation that .5 rounds upwards and leaves some of my calculations looking misrepresentative on inspection. Same with the round function, which leaves something like 2.5 becoming 2, not 3.

Or is this intentional?

Thanks,
Acute

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline overlord  
#2 Posted : 11 March 2021 02:46:04(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,128
Turkey

Was thanked: 509 time(s) in 339 post(s)
This is intentional.
Please pay attention to description.
Half to even, it is rounding to even number.
Even numbers are 2,4,6,8...
Odd numbers are 1,3,5,7...

If decimal part of number is even then it round downward to its base.
If decimal part of number is odd, it round upwards.
If you want always round to up when fraction is equal or bigger than .5;
You have to use away from zero rounding option.

https://en.wikipedia.org/wiki/Rounding#Round_half_to_even

Regards

2021-03-11_02-39.png

Edited by user 11 March 2021 03:29:00(UTC)  | Reason: Not specified

Offline overlord  
#3 Posted : 11 March 2021 03:44:42(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,128
Turkey

Was thanked: 509 time(s) in 339 post(s)
Originally Posted by: bugreportaccount Go to Quoted Post
Same with the round function, which leaves something like 2.5 becoming 2, not 3.

round() function when used with two parameters always do rounding with half to even.
If you want away from zero option in round() function, add third parameter and make it 1.

Regards.

2021-03-11_03-44.png
Offline bugreportaccount  
#4 Posted : 11 March 2021 09:09:08(UTC)
bugreportaccount

Rank: Newbie

Groups: Registered
Joined: 11/03/2021(UTC)
Posts: 4
New Zealand

I see, that does make sense now, appreciate the responses, especially the solution from overlord

Edited by moderator 11 March 2021 11:47:55(UTC)  | Reason: marked as SOLVED (not a bug)

Offline Jean Giraud  
#5 Posted : 11 March 2021 15:01:00(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: bugreportaccount Go to Quoted Post
Same with the round function, which leaves something like 2.5 becoming 2, not 3.

round.PNG


Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.