mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 16:37:57 +00:00
Weights to u64 + Balances Weights (#5446)
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -104,6 +104,10 @@ impl Fixed64 {
|
||||
int.saturating_sub(excess)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_negative(&self) -> bool {
|
||||
self.0.is_negative()
|
||||
}
|
||||
}
|
||||
|
||||
impl Saturating for Fixed64 {
|
||||
@@ -124,8 +128,7 @@ impl Saturating for Fixed64 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Note that this is a standard, _potentially-panicking_, implementation. Use `Saturating` trait
|
||||
/// for safe addition.
|
||||
/// Use `Saturating` trait for safe addition.
|
||||
impl ops::Add for Fixed64 {
|
||||
type Output = Self;
|
||||
|
||||
@@ -134,8 +137,7 @@ impl ops::Add for Fixed64 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Note that this is a standard, _potentially-panicking_, implementation. Use `Saturating` trait
|
||||
/// for safe subtraction.
|
||||
/// Use `Saturating` trait for safe subtraction.
|
||||
impl ops::Sub for Fixed64 {
|
||||
type Output = Self;
|
||||
|
||||
@@ -144,8 +146,7 @@ impl ops::Sub for Fixed64 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Note that this is a standard, _potentially-panicking_, implementation. Use `CheckedDiv` trait
|
||||
/// for safe division.
|
||||
/// Use `CheckedDiv` trait for safe division.
|
||||
impl ops::Div for Fixed64 {
|
||||
type Output = Self;
|
||||
|
||||
@@ -188,7 +189,13 @@ impl CheckedDiv for Fixed64 {
|
||||
impl sp_std::fmt::Debug for Fixed64 {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
||||
write!(f, "Fixed64({},{})", self.0 / DIV, (self.0 % DIV) / 1000)
|
||||
let integral = {
|
||||
let int = self.0 / DIV;
|
||||
let signum_for_zero = if int == 0 && self.is_negative() { "-" } else { "" };
|
||||
format!("{}{}", signum_for_zero, int)
|
||||
};
|
||||
let fractional = format!("{:0>9}", (self.0 % DIV).abs());
|
||||
write!(f, "Fixed64({}.{})", integral, fractional)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
|
||||
Reference in New Issue
Block a user