From e4cfb8b7a5616bdd47abbf7959b2c95a5f2d17cd Mon Sep 17 00:00:00 2001 From: lunar-mining Date: Thu, 30 Sep 2021 16:49:36 +0200 Subject: [PATCH] util: remove decimal point if round number --- src/util/parse.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/util/parse.rs b/src/util/parse.rs index 2d4aee4fd..28b0b59ac 100644 --- a/src/util/parse.rs +++ b/src/util/parse.rs @@ -167,12 +167,21 @@ mod tests { #[test] fn encode_base10() { - let input = 1500000000; + let input = 100000000; println!("Original input: {}", input); let mut input_str = input.to_string(); input_str.insert(1, '.'); + let amount = input_str.trim_end_matches('0'); + + let amount = if amount.ends_with('.') == true { + let amount = amount.trim_end_matches('.'); + amount + } else { + amount + }; + println!("Encoded output: {}", amount); } }