Take the 2-minute tour ×
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

I come from a programming background and I am trying to figure out how Bitcoin allows for divisibility. An example using high level code would also be nice.

I understand the high level basics of transactions (Bitcoin Transaction Diagram), but I am interested in divisibility specifically.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

A bitcoin is divisible to the eight decimal. The smallest portion of bitcoin has its own name: satoshi, whereas 1 BTC = 10^8 satoshis = 100,000,000 satoshis

To be completely correct, while in popular conversation the bitcoin is the predominant currency unit, in realitas the protocol uses satoshi. You can see this when looking at raw transactions or the ledger.

Whenever you send a transaction of bitcoins, the inputs are destroyed and new outputs are created. Essentially what happens with bitcoin works like this: Imagine you are paying for a $5 ice cream with a $10 bill, and the $10 bill is destroyed and replaced by two $5 bills, of which you get one $5 bill and one $5 bill goes to the ice cream vendor.

I was not able to deduce what you are trying to get code for, but if you want to split up bitcoins for transactions you might be looking for more information on how to create raw transactions.

share|improve this answer

All transactions are actually stored and transmitted in satoshis (one hundred millionths of a bitcoin or bitcoin * 10^8). So really, it is not divisibility, as much as it is converted by multiplying in the UI. It's always satoshis, but shown as various bigger units.

If you divide the the number of satoshis by 100m you get the value in bitcoin. If instead of dividing by 100m, you divide by 100k, you get mBTC (milli-bitcoin), if you divide by 100 you get uBTC (micro-bitcoin).

share|improve this answer
    
I don't think this is accurate. Bitcoins are divisible to satoshis, but transactions are sent in the desired amount. My understanding is that when a miner signs a block, that becomes the bitcoins, where this one unit was originally equal to 50 bitcoins. There being 50 bitcoins to a block was just an abstraction for the value of a block. –  Zamicol Sep 11 '13 at 19:33
1  
@Zach: aantonop is actually right, in the underlying protocol bitcoin values are always written as satoshis. I will also correct that in my answer. –  Murch Sep 12 '13 at 12:29
    
@Zach: no, you're confusing the monetary unit and blocks. Blocks are lists of transaction and form an authorative history for the network. Blocks are allowed to contain one transaction that conjures new currency out of nothing, under strictly controlled conditions, called the miner subsidy. So blocks do introduce new coins, they are not coins, and the amounts are always internally represented as multiples of a satoshi, even for subsidies. –  Pieter Wuille Sep 13 '13 at 23:43
    
Thanks Pieter and Murch! If I broke a ten dollar bill into two units, a $2.85 unit and a $7.15 cent unit, amounts are measured in pennies, but these units don't necessarily need to be transmitted or stored in pennies. The only case this would happen is if I actually broke them out into pennies. –  Zamicol Sep 14 '13 at 23:25
    
Unfortunately, there is no such thing as a $2.85 dollar bill. But in Bitcoin there is. Although we measure in satoshis, the actual units used are variable. –  Zamicol Sep 14 '13 at 23:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.