acton icon indicating copy to clipboard operation
acton copied to clipboard

Add i128 / u128

Open plajjan opened this issue 1 year ago • 3 comments

I think we should add 128 bit integer types. clang seems to support i128 & u128 just fine on all the platforms we currently target, so this should be fairly straight forward I think.

With the integer sub-typing hierarchy we have discussed, we would get a natural combined parent to i64 & u64, which is quite nice.

I expect 128 bit fixed integers to perform much better than our (big)ints. Like it can be passed in two registers and probably receive a fair dose of compiler optimizations.

@nordlander / @sydow what do you guys think?

plajjan avatar Apr 28 '24 08:04 plajjan

I have no idea hoe 128 bit integer arithmetic is handled on the platforms we support, but it seems likely that it, as Kristian suggests, would perform better than our present int type. And it would be easy to implement.

Johan must agree that the sub typing is as easy as it seems before we do more.

On 28 Apr 2024, at 10:36, Kristian Larsson @.***> wrote:

I think we should add 128 bit integer types. clang seems to support i128 & u128 just fine on all the platforms we currently target, so this should be fairly straight forward I think. With the integer sub-typing hierarchy we have discussed, we would get a natural combined parent to i64 & u64, which is quite nice. I expect 128 bit fixed integers to perform much better than our (big)ints. Like it can be passed in two registers and probably receive a fair dose of compiler optimizations. @nordlander / @sydow what do you guys think? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

sydow avatar Apr 29 '24 09:04 sydow

Indeed it is! Although I'm not really done implementing the current hierarchy, adding 128-bit types will be nothing but routine.

nordlander avatar Apr 29 '24 10:04 nordlander

It seems like there are fewer convenience things, like no built-in format string for printing 128 bit integers and no way to have 128 bit literals, but I guess the basic math bits are more or less there already. You are much better at judging these things anyway @sydow, so better you look at some point than me trying to sum up...

plajjan avatar Apr 30 '24 21:04 plajjan