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

Future-proof core integer dividingFullWidthReportingOverflow(_:) #142

Closed
oscbyspro opened this issue Jun 20, 2023 · 0 comments
Closed

Future-proof core integer dividingFullWidthReportingOverflow(_:) #142

oscbyspro opened this issue Jun 20, 2023 · 0 comments
Labels
brrr such code, much wow
Milestone

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Jun 20, 2023

From oscbyspro/Numberick#18

I'm not sure I'd consider this a bug, because it works, but it can be improved. Swift's documentation states that dividingFullWidth(_:) may cause a run-time error in the case of overflow. Well, it doesn't, and I'm using the current behavior in my implementation of [...]ReportingOverflow(_:). Here's the relevant line, but not the whole method:

var qro = NBK.bitCast(PVO(rhsMagnitude.dividingFullWidth(lhsMagnitude), lhsMagnitude.high >= rhsMagnitude)) as PVO<QR<Self, Self>>

While this is correct in Swift 5.8, it may or may not be future-proof. I could reimplement the entire dividing thingy, but that's a pain. Alternatively, I can do the truncation myself then pass the value to dividingFullWidth(_:).

@oscbyspro oscbyspro added the brrr such code, much wow label Jun 20, 2023
@oscbyspro oscbyspro added this to the v3.1.0 milestone Jun 20, 2023
oscbyspro added a commit that referenced this issue Jun 20, 2023
oscbyspro added a commit that referenced this issue Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brrr such code, much wow
Projects
None yet
Development

No branches or pull requests

1 participant