Solidity – Understanding the Logic Behind Q64.96 Number

bignumberethereumjssolidityuniswap

Checking the math behind uniswap v3 and I constantly seeing the term: Q64.96 in sqrtRatioX96

I am just wondering if this is a naming convention in smart contract world to describe the format of the number? if so, what does it exactly mean? (Not asking the pricing logic behind Uniswap v3)

https://docs.uniswap.org/protocol/reference/core/libraries/SqrtPriceMath

Best Answer

This looks like a notation in math: https://en.wikipedia.org/wiki/Q_(number_format)

For example, the specification Q3.12 describes a signed binary fixed-point number with a w = 16 bits in total, comprising the sign bit, three bits for the integer part, and 12 bits that are assumed to be fraction. That is, a 16-bit signed (two's complement) integer, that is implicitly multiplied by the scaling factor 2−12