13 ms·
What sorts of applications/domains need or benefit from having 128 bit integers?
by aroman 10y ago
What sorts of applications/domains need or benefit from having 128 bit integers?
- gravypod 10y agoFinance and scientific computing.
- foota 10y agoIs this for implementing faster high precision floating point? It didn't mention 128 bit float.
- gravypod 10y agoFor finance probably but it's mostly useful for statistics from what I understand. I know fortran and Cobol code that banks use and is used for science (tm) often defines numbers this large for certain operations. One such i can think of is a map reduce of large datasets. Let's say you want to find as a result a huge sum. 2^128 is a bit bigger then 2^64 and that difference may be big enough to provide the computation needed for getting to Mars rather then getting to the moon on 2^8 machines.
- foota 10y agoFun fact: there are ~2^50 millimetres from here to mars
- spladug 10y agoThere are? It looks closer to 2^14. 2^50mm is around 7.5 au. Sorry to nitpick, but I thought this was a super interesting point!
- Dylan16807 10y agoI assume you meant to type 47 rather than 14?
- foota 10y agoI rounded a bit over-zealously, thanks for nit picking. It is indeed 2^47.6333. (also assuming you meant 47 not 14.)
- spladug 10y agoWell, that's embarrassing. 2^47 it is! :)
- Keyframe 10y ago128i[3] would be enough for 390x observable universe discrete grid in Euclidean space with nanometer precision. Or 0.39 observable universe with picometer resolution.
- leereeves 10y agoWhat number in finance is bigger than 2^64?
- wtallis 10y agoThe sum of the whole planet's annual GDPs, expressed as US dollars with a precision of cents, requires about 53 bits. Choose a smaller unit or start considering long time spans, and you can easily get uncomfortably close to overflow.
- leereeves 10y agoWhy would you express GDPs, which are estimated to an accuracy of millions of US dollars, with a precision of US cents?
- wott 10y agoRiches are getting richer.
- justincormack 10y agoPOWER9 has hardware 128 bit float, so likely to start becoming relevant soon.
- planteen 10y agoTwo applications off the top of my head: Reed-Solomon encoding and bigint math.
- mambodog 10y agocan be handy for a really big space for ids, especially if you don't want to use strings. also bigger bitsets
- pkulak 10y agoGUIDs are usually 128 bits. So are IPv6 addresses. Could be nice to store them in a single, native type? Probably no easier than a byte array though...
- PeCaN 10y agoNeither one is used like an integer though. As in, you don't really add GUIDs together¹, so there's no real benefit over a byte array or struct. 1. I guess having bit mask operations for IPv6 addresses could be useful.
- drfuchs 10y agoBut you do want to compare GUIDs. And hash them, which can involve shifting, adding, xor'ing, multiplying, remaindering, etc.
- Gankro 10y agoIf you can't already hash/compare an array of bytes, something terrible has happened with your language design.
- rickycook 10y agowell, you can already do operations on 128bit of data that represents and int as well, but that's a kind of silly thing to say because higher level abstractions are just about making things easier. so now you can do it in 1 operation rather than several; if that's all you gain, then it's still worth it
- drfuchs 10y agoNot in a way that complies into one or two machine instructions. So, your array code is an order of magnitude or two too slow. Never mind having to write it at all. Added: I'm talking about implementing specific, optimized hash functions on 128-bit values (e.g. GUIDs, IPv6 addresses), and not generic hash functions that can take any length input (although many of them speed up linearly in the size of int that gets used internally).
- 0xcde4c3db 10y agoThe main operation I can think of is multiplying by a ratio without losing precision. If all your values are specified in 64-bit fixed point, a 128-bit integer type gives you something with enough bits for the intermediate product. It's not something I've really dealt with myself, but I seem to remember reading that this is really handy to have in some physics simulations and control system algorithms that do numerical integration. At any rate, it's important enough that many Forth dialects have a word for this specific operation [1]. [1] https://www.forth.com/starting-forth/5-fixed-point-arithmetic/#Star-slash_the_Scalar https://www.forth.com/starting-forth/5-fixed-point-arithmeti...
- astrobe_ 10y agoOr more generally fixed point with big numbers and lots of decimals.
- Someone 10y agoThat's less of a concern for 64-bit (even for signed arithmetic, intermediary results can be close to 1.0E19) than for the typical 16-bit values and intermediary 32-bit result that Forth was designed for. It also is a lot less of a concern on modern systems, where floating point operations aren't much slower than integer ones.
- loeg 10y ago(Some) NVMe statistics are specified as 128-bit integers. Not that you need to operate on them, necessarily, or that they'll practically ever exceed 64-bit values, but they are.
- MichaelBurge 10y agoYou can store a bitboard for western chess perfectly with 64-bit integers. Some other chess variants(like Chinese Chess, or Shogi) need 128 bits for the same techniques, since the board is larger. I haven't used it, but Julia lets you declare any(?) fixed size bitset. Which would probably come in handy for Go.
- baby 10y agoAES blocks!
- drfuchs 10y agoImplementing cryptographic hash functions like SHA-3 (see the original Kaccek paper for specific results under various 32-bit, 64-bit, and 128-bit native integer hardware support). And implementing other, faster but non-cryptographic hash functions like Spooky, etc.
- calanya 10y agoMeasuring time in picoseconds. The current unix timestamp is roughly 2^70 picoseconds, so won't fit in 64 bits.
- qwertyuiop924 10y ago...PS2 hacking? But I don't think rust has support for the Emotion Engine in any case.
- cesarb 10y agoOne example I know of is the Poly1305 MAC algorithm, which at its core multiplies two numbers and reduces the result modulo 2^130-5. The C implementation at https://github.com/floodyberry/poly1305-donna https://github.com/floodyberry/poly1305-donna shows three ways to represent the 130-bit numbers during the calculation: as ten 13-bit limbs, as five 26-bit limbs, or as two 44-bit limbs plus one 42-bit limb. In the middle of the multiplication, before the carries are propagated, you need twice the number of bits: the first option needs 26 bits, which can be done with a 16x16->32 bit multiplication. The second option needs 52 bits, which can be done with a 32x32->64 bit multiplication. The last option, however, needs 88 bits, which won't fit in 64 bits; you need a 128-bit integer, so you can do a 64x64->128 bit multiplication. At least on x86-64, the 64x64->128 bit multiplication is a single instruction, like the 32x32->64 bit and the 16x16->32 bit multiplications. Doing the calculation with only three limbs is clearly faster than doing it with five limbs; to start with, using 3 limbs you need 9 multiplies, while with 5 limbs you have to do 25 multiplies. The carry propagation and reduction steps also take time proportional to the number of limbs.
- Ericson2314 10y ago128-bit atomics for small structs—very convenient
- ycmbntrthrwaway 10y agoNS-3 network simulator uses 128bit integers to measure time and they have 3 implementations (search page for int64x64): http://code.nsnam.org/ns-3-dev/file/38d46996c708/src/core/model http://code.nsnam.org/ns-3-dev/file/38d46996c708/src/core/mo... It would be much easier for them to just build on top of i128. Also, you can see that one of the implementations is copied from Cairo, so it seems graphics libraries have some use for 128-bit integers too.
- runeks 10y agoI found myself asking the same question. 64 bit integers are useful because you'll never fill up an IntMap with a uint64 key, and 256 bit integers are useful because they offer sufficient (128 bit) collision resistance. In my mind, a uint128 is too big for use as an index, and too small as a GUID.