Added billion
Will add a way to do check up to thousandth's place next
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
# ntext-rs
|
# ntext-rs
|
||||||
|
|
||||||
|
[](https://github.com/uttarayan21/ntext-rs/actions/workflows/docs.yaml)
|
||||||
|
[](https://github.com/uttarayan21/ntext-rs/actions/workflows/rust.yaml)
|
||||||
|
|
||||||
Documentation of [ntext-rs](https://uttarayan21.github.io/ntext-rs) generated by cargo doc.
|
Documentation of [ntext-rs](https://uttarayan21.github.io/ntext-rs) generated by cargo doc.
|
||||||
|
|
||||||
A rust library to get numbers (usize) as words
|
A rust library to get numbers (usize) as words
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ impl<'format> Formatting<'format> {
|
|||||||
tens_seperator: None,
|
tens_seperator: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// With same formatting for all
|
/// With same formatting for all seperators
|
||||||
pub fn with_seperator(seperator: &'format str) -> Self {
|
pub fn with_seperator(seperator: &'format str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
capitalize: false,
|
capitalize: false,
|
||||||
|
|||||||
+13
-1
@@ -47,6 +47,12 @@ fn place_value(number: u8, place: u8, fmt: &Formatting) -> Option<String> {
|
|||||||
4 => buffer.push_str("Thousand"),
|
4 => buffer.push_str("Thousand"),
|
||||||
5 => (), // Souldn't happen
|
5 => (), // Souldn't happen
|
||||||
6 => buffer.push_str("Million"),
|
6 => buffer.push_str("Million"),
|
||||||
|
7 => (),
|
||||||
|
8 => (),
|
||||||
|
9 => buffer.push_str("Billion"),
|
||||||
|
10 => (),
|
||||||
|
11 => (),
|
||||||
|
12 => buffer.push_str("Trillion"),
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -57,6 +63,12 @@ fn place_value(number: u8, place: u8, fmt: &Formatting) -> Option<String> {
|
|||||||
4 => buffer.push_str("thousand"),
|
4 => buffer.push_str("thousand"),
|
||||||
5 => (), // Souldn't happen
|
5 => (), // Souldn't happen
|
||||||
6 => buffer.push_str("million"),
|
6 => buffer.push_str("million"),
|
||||||
|
7 => (),
|
||||||
|
8 => (),
|
||||||
|
9 => buffer.push_str("billion"),
|
||||||
|
10 => (),
|
||||||
|
11 => (),
|
||||||
|
12 => buffer.push_str("trillion"),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +151,7 @@ fn tens_place(tens: u8, ones: u8, fmt: &Formatting) -> Option<String> {
|
|||||||
pub fn to_text_fmt(number: usize, fmt: &Formatting) -> String {
|
pub fn to_text_fmt(number: usize, fmt: &Formatting) -> String {
|
||||||
let mut numtext: String = String::new();
|
let mut numtext: String = String::new();
|
||||||
let mut last: Option<u8> = None;
|
let mut last: Option<u8> = None;
|
||||||
let tens_place_holders: [u8; 3] = [2, 5, 7];
|
let tens_place_holders: [u8; 4] = [2, 5, 7, 10];
|
||||||
let digits: Vec<u8> = number
|
let digits: Vec<u8> = number
|
||||||
.to_string()
|
.to_string()
|
||||||
.chars()
|
.chars()
|
||||||
|
|||||||
Reference in New Issue
Block a user