Is there a way to define a single digit base6 number that can only be the decimal values 0-5?
Or a different way to ask. Is there a way to limit a decimal value in the range of 0-5 such that num :Base6= 6 would give a compiler error?
My ultimate goal is to have [3]Base6 definition, where each position in the array is limited to range 0-5
I’ve made an attempt with bit_fields, but the best I can get is base4 or base 8. The reasons why make total sense to me. Just wondering if there is an approach others use to define custom base numbers without using strings.
Base4 :: bit_field u8 {
num: u8 | 2
}
Base8 :: bit_field u8 {
num: u8 | 3
}
base4: Base4
base4.num = 3
Plus I’d also have to reference the “num” name, which I’d also like to drop if possible.
I am aware of how to do a base2 to base6 or base10 to base6 conversion with a procedure. What I’m trying to do is get a more granular definition, so that my procedure does not have to return a false bool if a number input is outside the range 0-5. I’d like to push that error to the compiler if possible so that language servers can pick it up while coding.