aboutsummaryrefslogtreecommitdiff
path: root/vendor/number_prefix/examples/conversions.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/number_prefix/examples/conversions.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/number_prefix/examples/conversions.rs')
-rw-r--r--vendor/number_prefix/examples/conversions.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/vendor/number_prefix/examples/conversions.rs b/vendor/number_prefix/examples/conversions.rs
deleted file mode 100644
index 422d116..0000000
--- a/vendor/number_prefix/examples/conversions.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-/// This example prints out the conversions for increasingly-large numbers, to
-/// showcase how the numbers change as the input gets bigger.
-/// It results in this:
-///
-/// ```text
-/// 1000 bytes is 1.000 kB and 1000 bytes
-/// 1000000 bytes is 1.000 MB and 976.562 KiB
-/// 1000000000 bytes is 1.000 GB and 953.674 MiB
-/// 1000000000000 bytes is 1.000 TB and 931.323 GiB
-/// 1000000000000000 bytes is 1.000 PB and 909.495 TiB
-/// 1000000000000000000 bytes is 1.000 EB and 888.178 PiB
-/// 1000000000000000000000 bytes is 1.000 ZB and 867.362 EiB
-/// 1000000000000000000000000 bytes is 1.000 YB and 847.033 ZiB
-///
-/// 1024 bytes is 1.000 KiB and 1.024 kB
-/// 1048576 bytes is 1.000 MiB and 1.049 MB
-/// 1073741824 bytes is 1.000 GiB and 1.074 GB
-/// 1099511627776 bytes is 1.000 TiB and 1.100 TB
-/// 1125899906842624 bytes is 1.000 PiB and 1.126 PB
-/// 1152921504606847000 bytes is 1.000 EiB and 1.153 EB
-/// 1180591620717411300000 bytes is 1.000 ZiB and 1.181 ZB
-/// 1208925819614629200000000 bytes is 1.000 YiB and 1.209 YB
-/// ```
-
-extern crate number_prefix;
-use number_prefix::NumberPrefix;
-use std::fmt::Display;
-
-
-fn main() {
-
- // part one, decimal prefixes
- let mut n = 1_f64;
- for _ in 0 .. 8 {
- n *= 1000_f64;
-
- let decimal = format_prefix(NumberPrefix::decimal(n));
- let binary = format_prefix(NumberPrefix::binary(n));
- println!("{:26} bytes is {} and {:10}", n, decimal, binary);
- }
-
- println!();
-
- // part two, binary prefixes
- let mut n = 1_f64;
- for _ in 0 .. 8 {
- n *= 1024_f64;
-
- let decimal = format_prefix(NumberPrefix::decimal(n));
- let binary = format_prefix(NumberPrefix::binary(n));
- println!("{:26} bytes is {} and {:10}", n, binary, decimal);
- }
-}
-
-
-fn format_prefix<T: Display>(np: NumberPrefix<T>) -> String {
- match np {
- NumberPrefix::Prefixed(prefix, n) => format!("{:.3} {}B", n, prefix),
- NumberPrefix::Standalone(bytes) => format!("{} bytes", bytes),
- }
-}