bitcoin-elixir v0.0.1 Bitcoin.Block.CompactBits
256-bit target threshold in the block header is encoded in a 32-bit space (compact bits a.k.a nBits). This module provides functions to encode and decode compact bits.
Simple and understandable explanation: http://bitcoin.stackexchange.com/questions/2924/how-to-calculate-new-bits-value
Summary
Functions
Docede compact bits integer to target integer
Encode target integer to compact bits integer