Skip to content

Fix the rounding of the values in the city ministats - #15312

Open
JPBergsma wants to merge 2 commits into
yairm210:masterfrom
JPBergsma:fix_round_minimenu
Open

Fix the rounding of the values in the city ministats#15312
JPBergsma wants to merge 2 commits into
yairm210:masterfrom
JPBergsma:fix_round_minimenu

Conversation

@JPBergsma

Copy link
Copy Markdown

The function round() was used to round the values in the city stat minimenu. This function however rounds values ending in .5 to the nearest even integer. For determening the amount of generated food .5 is however rounded up. Therefore, I changed the rounding so values ending in .5 are always rounded up.

@SomeTroglodyte

Copy link
Copy Markdown
Collaborator

Welcome! I agree banker's rounding is for bankers, not logically thinking people. However, roundToInt is an alternative in the standard library that already does sensible rounding. Plus, it's consistent for negative values and yours isn't - surprise - toInt() is toward zero, it doesn't floor first. Not that we'll often see negative values here...

@JPBergsma

Copy link
Copy Markdown
Author

Ah yes, I see your point. Gold values do go negative fairly often so that would definitely be a problem.
I have changed the rounding method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants