There are no decimal places in bitcoin and it is best we don't introduce them ever either. Floating point numeric types are a headache and can introduce bugs in a lot of implementations in different programming languages, not to mention they are slower.
With that said a simple solution can be this, which has the benefit of decreasing the transaction size too!
This is based on
a naive research I did 2 years ago that showed changing every
UInt32 in a block to
CompactInt could empty the block size by up to 50 kilo bytes.
- This assumes we do need this increase
- For easy calculation price of bitcoin is assumed to be $1 million
- Also the supply has to change from 21000000_00000000 to a fixed value of 21000000_00000000_00000000 (which is similar to 8 more decimal places)
The amount field in transactions can be changed from a
UInt64 integral type to a new custom type that is similar to
CompactInt but is
mostly similar to what DER uses to encode lengths.
First bit, if set, indicates that first byte is the length of the bytes to read. The follow up bytes are the value itself.
To send $100 worth of bitcoin that is 0.00010000_00000000
BTC in 16 decimal place representation and 0x0010a5d4e8 in little-endian hexadecimal representation we need 6 bytes. A first byte = 0x85(=0b10000101) followed by the amount. 0x850010a5d4e8. This saves up on 10 bytes.
This can be implemented using transaction version field. Every transaction that has version below 3 has amount field that is the current design of being a
UInt64 and has to be multiplied by 10
8, every transaction with version 3+ has amount field set to the new format.
What this does is avoiding unnecessary complications while giving the implementations the advantage of speed and accuracy of regular integral numeric types. For 99% of the cases amounts sent are going to be smaller than a
UInt64 so all the computations are fast and easy, anything bigger (worth >$1.84 billion) is going to be rare and computation requires 2
UInt64 which is still pretty easy, fast and 100% accurate.
Fee calculation and other conditions are still the same and easily calculated in this design.