SQLite Forum

Decimal128
Login
> What we're discussing in this thread is a) going straight to 128 bits, rather than something more moderate like 80 or 96 bit; and b) decimal representation, which is better for countable things rather than measurable things, which brings us back to questions of the maximum number of tightly-packed dust particles in the visible universe.

If you read the IEEE Standards document, there actually IS a big reason to jump to 128-bit formats. The 32 / 64 / 128-bit formats are described as 'Basic Floating-Point Formats' and formats and are fully specified. Other formats like 80 and 96 are recognized and allowed and are called extended Floating-Point formats, and are NOT fully defined. There are allowed several different versions of 'Float80' with differing allocations of bits between Exponent and Mantissa, with just the restriction of needing at least as many as Float64, and no more than Float128, thus, the 128-bit is the next truly standardized, and thus most portable format. (It might not be available, but if it is, it WILL work and not give crazy values)

Decimal format floating-point makes sense if for legal, or other purposes you want to exactly mimic how paper and pencil match would work with numbers with decimal fractions. SOMETIMES you can replace that with scaled fixed point, but sometimes that overcomplicates the algorithm, especially if at times you need to deal with decimal fractions of that basic unit. This is the basic historical reason that the Decimal Floating-Point Format was invented because sometimes people want to make computers really do things to get the same answer that we would if we did it by hand, and we use decimals. Yes, it shouldn't really matter if the World GDP isn't computed accurately to the penny, but sometimes people are illogical and make demands like that.