What's the decimal storage requirement in ms sql for bitcoin?
GAAP standard quotes decimal (13, 4) for money.
Is decimal (13,8) preferred for bitcoin or something else?
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.Sign up to join this community
You need at least
DECIMAL(16,8) to store any valid Bitcoin amount (i.e. up to just over 20 Million Bitcoin, requiring 8 digits to the left of the decimal point) precisely (i.e. down to a single Satoshi, requiring 8 digits to the right of the decimal point).
Depening on your application and how you (or your collaborators) think of Bitcoin amounts, it may be preferable to process them in Satoshi, enabling you to treat them as integers (
BIGINT would then be the SQL datatype). Of course, then you have traded the dangers around non-integer handling for those associated with large integer handling.
I would take a different approach and simply use an 8-byte integer value. This is because all bitcoin transaction values are stored as integers and since
float decimal math can vary from architecture to architecture, I'd recommend using integer values whenever possible.
Bitcoin has a fixed decimal place of 8-digits. If you want to display this information to an end-user just format the integer value to represent the appropriate number of decimals, when the value needs to be displayed.