3 ms·
What platform has 128-bit integer support to where that was an important thing to add to the primitive types?
by seanw444 2y ago
What platform has 128-bit integer support to where that was an important thing to add to the primitive types?
- bluepizza 2y agoIPv6 and ZFS use 128-bit integers - I suspect this is why this primitive was added.
- stephencanon 2y ago(Author and implementer of the Swift Int128 proposal here) There's lots of one-off uses for 128-bit integers scattered around systems programming (and programming in general, I just happen to come from more of a systems background). Individually using a pair of 64b integers for each case is totally workable, but eventually life is easier if you just have an Int128 type. There's not really any one use case that drove their inclusion in the standard library, rather lots of times that we were saying "it would be kind of nice if we had this".
- easeout 2y agoThanks for your work!
- LegionMammal978 2y agoMany platforms have an instruction to get the upper 64-bit word of a widening 64×64-bit multiplication. But it can be difficult to (performantly) access such instructions from anything higher-level than assembly, so well-optimized language support for 128-bit integers can open this up.
- stephencanon 2y agoSwift had made this available for a long time via multipliedFullWidth (SE-0104, implemented in Swift 4.0), no Int128 required. E.g.: https://godbolt.org/z/dvMefahdq https://godbolt.org/z/dvMefahdq
- eknkc 2y agoAs a side note, zig supports arbitrary width integers. I'd like more languages to support that. You can have i7, i3, i1024 or whatever you want (I guess up to some limit). Makes it a lot easier to handle packed binary files etc.
- jazzyjackson 2y agoMaybe something to do with AES 128bit blocks