I put the files on my Gist. It is a continuation of trying to make a sample numeric type like the built-in integers. This is not the first thread I've made on this.
I try punting to work someone else has done. I didn't see an Int4
, but I did see someone trying an UInt4
on GitHub. I made an adaptation of UInt4
, then tried making a signed version.
I'm wondering: is this right and complete (for now)? I'm using Xcode 10 beta on macOS High Sierra. I think it's in Swift 4.2 (beta) mode. A weird complication that persists from the previous thread is that the code gets so complex that Swift forgets default implementations, so you have to supply some lower-level ones that technically you shouldn't have too.
The reason I'm making these types? It's for trying out a multi-digit type. For the purposes of testing out carries and such, a digit type with only 16 states is a lot easier to reason out than 4 billion or 18 quintillion states (depending on whether Int
is 32 or 64 bits).