Skip to content

Specify precision / tolerance for interest checks in "Interest Is Interesting" - #2501

Merged
ErikSchierboom merged 1 commit into
exercism:mainfrom
BNAndras:update-interest-is-interesting
Nov 24, 2026
Merged

ErikSchierboom merged 1 commit into
exercism:mainfrom
BNAndras:update-interest-is-interesting

Conversation

@BNAndras

Copy link
Copy Markdown
Member

Related to #2500 and https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/11/decimal-biginteger-floating-point-conversions. This should be merged so the other PR can then be rebased for CI purposes. It shouldn't hopefully break solutions on .NET 10 or .NET 11.

@github-actions

Copy link
Copy Markdown
Contributor

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

public void Interest_on_negative_balance()
{
Assert.Equal(-321.3m, SavingsAccount.Interest(-10000.0m));
Assert.Equal(-321.3m, SavingsAccount.Interest(-10000.0m), precision: 4);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the precision by 1 here as there is just a single decimal point being checked?

If so, the other tests also need to be updated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a copy and paste error from Interest_on_large_balance that I forgot to update. That should have been a precision of 1.

For Interest_on_negative_balance, a precision of 1 would compare -321.3 to -321.3.

Expected: -321.3
Actual:   -321.3000059127807617187500000

For Interest_on_medium_balance, a precision of 3 would compare 81.050 vs 81.050.

Expected: 81.0498379
Actual:   81.04984047491550445556640625

For Interest_on_large_balance, a precision of 4 would compare 856.3698 vs 856.3698.

Expected: 856.3698
Actual:   856.3697670021057128906250000

So for that set, I think the precisions are reasonable.

@ErikSchierboom
ErikSchierboom merged commit 073e928 into exercism:main Nov 24, 2026
8 checks passed
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