-
Notifications
You must be signed in to change notification settings - Fork 3
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
Signed<Magnitude> #81
Comments
Subquestion: if it's not possible, which set of changes would enable it? |
Making Signed<Magnitude> super light-weight, with no 2's complement and no fixed-width, is also an option. More on this: I could introduce a non-binary NBKInteger protocol, that's like Swift.Numeric + division + words. |
I do love the light-weight approach. It's a high-value-low-maintenance coffee break project. |
I would need some composable magnitude text conversion methods, but that's easy to add. |
I'll need to make some changes, but it seems viable. I like it because it doesn't try to be something it is not, meaning it plays to its strengths and not to its weaknesses. It's much simpler that way and way easier to maintain. It also leaves a spot open for a two's complement solution, should I find the time or need it (#44). |
// in NBKSignedKit/NBKSigned.swift
#if canImport(NBKFlexibleWidthKit)
import NBKFlexibleWidthKit
public typealias SIntXL = NBKSigned<UIntXL>
#endif |
Sign & magnitude encoding can be exposed in TextKit (#86), so I won't need another protocol method for that. |
Conforming this model to |
Hm. I kind of feel like this is teetering on the edge of over-engineering. Maybe I'll add a concrete sign-magnitude model to NBKFlexibleWidthKit and drop NBKSigned<Magnitude>. Dunno, I'll decide when I get to it. |
There's only two interesting specializations of it: UInt and UIntXL. |
The final thing I want to investigate before committing to a flexible-width solution is whether I can efficiently model the signed part as a
Signed<Magnitude>
wrapper. I know fixed-width is possible, but that's different.The text was updated successfully, but these errors were encountered: