Merge rust-bitcoin/rust-bitcoin#1713: Swap out `Work::log2` implementation for `U256::to_f64`
4924148dc6
Swap out `Work::log2` implementation for `U256::to_f64` (junderw) Pull request description: See: https://github.com/rust-bitcoin/rust-bitcoin/pull/1707#issuecomment-1464052971 ACKs for top commit: Kixunil: ACK4924148dc6
apoelstra: ACK4924148dc6
Tree-SHA512: 39d5d10b65c9597df1103df1639c57d432f04798b4b2be990b59275b8bd1f08560f72db8cda9edafad202ed0e4bf16cef7798279841b2d713ed482855498d1fe
This commit is contained in:
commit
35cff6a2ef
|
@ -92,12 +92,7 @@ impl Work {
|
|||
/// `log2_work` output in its logs.
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
pub fn log2(self) -> f64 {
|
||||
let U256(high, low) = self.0;
|
||||
// 2^128 * high + low
|
||||
let double = (3402823669209385e23_f64 * high as f64) + (low as f64);
|
||||
double.log2()
|
||||
}
|
||||
pub fn log2(self) -> f64 { self.0.to_f64().log2() }
|
||||
}
|
||||
do_impl!(Work);
|
||||
|
||||
|
|
Loading…
Reference in New Issue