mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-01-21 12:38:34 +01:00
Trimmed end matches of dots in order to avoid numbers such as 1.
.
This commit is contained in:
parent
64083eca82
commit
ada3fc52f9
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -138,7 +138,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kalk"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
dependencies = [
|
||||
"phf",
|
||||
"regex",
|
||||
@ -148,7 +148,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kalk_cli"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"kalk",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kalk"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
authors = ["PaddiM8"]
|
||||
edition = "2018"
|
||||
readme = "README.md"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "kalk_cli"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
authors = ["PaddiM8"]
|
||||
edition = "2018"
|
||||
readme = "../README.md"
|
||||
@ -11,7 +11,7 @@ keywords = ["math", "calculator", "cli", "command-line"]
|
||||
categories = ["mathematics", "command-line-utilities"]
|
||||
|
||||
[dependencies]
|
||||
kalk = { path = "../kalk", version = "^0.1.8" }
|
||||
kalk = { path = "../kalk", version = "^0.1.9" }
|
||||
rustyline = "6.1.2"
|
||||
ansi_term = "0.12"
|
||||
regex = "1"
|
||||
|
@ -19,7 +19,11 @@ pub fn eval(parser: &mut parser::Context, input: &str) {
|
||||
format!("0.{}{}", "0".repeat(exp.abs() as usize), digits)
|
||||
} else if use_sci_notation || result.fract() != 0 {
|
||||
// Insert the comma if there are supposed to be decimals.
|
||||
let mut chars: Vec<char> = digits.trim_end_matches('0').chars().collect();
|
||||
let mut chars: Vec<char> = digits
|
||||
.trim_end_matches('0')
|
||||
.trim_end_matches('.')
|
||||
.chars()
|
||||
.collect();
|
||||
chars.insert(comma_pos, '.');
|
||||
chars.into_iter().collect::<String>()
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user