You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is sometimes the case with integers, that you may want to take signed arguments and return unsigned integer of exactly the same byte size. One example is calculating greatest common divisor, if you care about handling the case of GDC(min(T), min(T)).
Consider a dummy casting procedure:
toUnsigned :: proc (A: i32) -> u32
If you care about all byte sizes, then - as far as I'm aware - there is no easy way of expressing it as a generic (if you want to remain explicit about size, rather than using "int" and "uint", possibly with type casting in when statements) and you have to type out all cases manually. Which is fair, as they are two distinct types, but maybe could be resolved at the level of parser with some additional syntax.
For example: toUnsigned :: proc (A: $T) -> UT where intrinsics.type_is_integer(T) && signed_unsigned_pair(T, UT) toUnsigned :: proc (A: $int(T)) -> uint(T) where intrinsics.type_is_integer(T) toUnsigned :: proc (A: $signed(T)) -> unsigned(T) where intrinsics.type_is_integer(T)
Or even more general, with "same_size_int", "same_size_uint", "same_size_float".