-
-
Save stevenroose/f47e6e63f63c1922b938bc50c9f8e64f to your computer and use it in GitHub Desktop.
Revisions
-
stevenroose revised this gist
Jan 21, 2020 . 1 changed file with 8 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ pub fn fmt_value_in(&self, f: &mut fmt::Write, denom: Denomination) -> fmt::Result { let sats = match self.as_sat().checked_abs() { Some(sats) => sats, None => { assert_eq!(self.as_sats(), i64::min_value()); 2147483648 // u64::max_value() - self.as_sat() as u64 + 1 } }; fmt_satoshi_in(sats, self.is_negative(), f, denom) } -
rust-play created this gist
Jan 21, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ pub fn fmt_value_in(&self, f: &mut fmt::Write, denom: Denomination) -> fmt::Result { let sats = self.as_sat().checked_abs().map(|a: i64| a as u64).unwrap_or_else(|| { // We could also hard code this into `2147483648` u64::max_value() - self.as_sat() as u64 +1 }); fmt_satoshi_in(sats, self.is_negative(), f, denom) }