Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed decimalExpansion #82

Merged
merged 2 commits into from
Mar 1, 2024
Merged

Fixed decimalExpansion #82

merged 2 commits into from
Mar 1, 2024

Conversation

tingwoo
Copy link
Contributor

@tingwoo tingwoo commented Feb 29, 2024

I think I've fixed the issue with decimalExpansion rounding. (issue #72)
Now, when inputting 7450921770987 / 7450936270987

let num = BDouble("7450921770987", over: "7450936270987")!
print(num.decimalDescription)
for i in 0...8 {
    print(num.decimalExpansion(precisionAfterDecimalPoint: i))
}

it'll give

1.0000
1.
1.0
1.00
1.000
1.0000
1.00000
0.999998
0.9999981
0.99999805

which are the correct answers.

@tingwoo tingwoo changed the title fix decimal expansion Fixed decimalExpansion Feb 29, 2024
@mkrd
Copy link
Owner

mkrd commented Feb 29, 2024

Hey @tingwoo thanks a lot! I would be super thankful if you could add these to the test cases as well, so we know for sure that future changes will not break this!

@tingwoo
Copy link
Contributor Author

tingwoo commented Feb 29, 2024

Done! I didn't notice that BDouble("2")!.decimalExpansion(precisionAfterDecimalPoint: 0) should give 2.0 instead of 2, so I also implemented that in the last commit.
By the way, I can't get the tests to run on my machine (it says "No such module 'MGTools'"), do you perhaps have any ideas on why?

@mkrd
Copy link
Owner

mkrd commented Mar 1, 2024

Thanks for adding the tests, great! I'm not sure why you get the error, but I will be looking into it

@mkrd mkrd merged commit 158f802 into mkrd:master Mar 1, 2024
2 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