Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created April 23, 2019 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/0897cc40be4f02083e6c97b06ded8870 to your computer and use it in GitHub Desktop.
Save rust-play/0897cc40be4f02083e6c97b06ded8870 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn bitcoin_block_reward(height: u64) -> u64 {
let coin = 100000000.0;
let reward_base = 50.0 * coin;
let reward_halving = 210000.0;
let result = reward_base / (2.0 as f64).powf((height as f64 / reward_halving).floor());
result.floor() as u64
}
fn main() {
println!("{}", bitcoin_block_reward(1489218));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment