mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 20:17:45 +00:00
seq: Move extendedbigdecimal.rs to uucore/features/format
Will make it possible to directly print ExtendedBigDecimal in `seq`, and gradually get rid of limited f64 precision in other tools (e.g. `printf`). Changes are mostly mechanical, we reexport ExtendedBigDecimal directly in format to keep the imports slightly shorter.
This commit is contained in:
parent
b4a9b89f4a
commit
2103646ff7
8 changed files with 15 additions and 12 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3504,6 +3504,7 @@ dependencies = [
|
|||
name = "uucore"
|
||||
version = "0.0.30"
|
||||
dependencies = [
|
||||
"bigdecimal",
|
||||
"blake2b_simd",
|
||||
"blake3",
|
||||
"chrono",
|
||||
|
@ -3523,6 +3524,7 @@ dependencies = [
|
|||
"md-5",
|
||||
"memchr",
|
||||
"nix",
|
||||
"num-traits",
|
||||
"number_prefix",
|
||||
"os_display",
|
||||
"regex",
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore extendedbigdecimal bigdecimal hexdigit numberparse
|
||||
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
||||
use crate::number::PreciseNumber;
|
||||
use crate::numberparse::ParseNumberError;
|
||||
use bigdecimal::BigDecimal;
|
||||
use num_traits::FromPrimitive;
|
||||
use uucore::format::ExtendedBigDecimal;
|
||||
|
||||
/// The base of the hex number system
|
||||
const HEX_RADIX: u32 = 16;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// spell-checker:ignore extendedbigdecimal
|
||||
use num_traits::Zero;
|
||||
|
||||
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
||||
use uucore::format::ExtendedBigDecimal;
|
||||
|
||||
/// A number with a specified number of integer and fractional digits.
|
||||
///
|
||||
|
|
|
@ -15,9 +15,9 @@ use num_bigint::Sign;
|
|||
use num_traits::Num;
|
||||
use num_traits::Zero;
|
||||
|
||||
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
||||
use crate::hexadecimalfloat;
|
||||
use crate::number::PreciseNumber;
|
||||
use uucore::format::ExtendedBigDecimal;
|
||||
|
||||
/// An error returned when parsing a number fails.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
|
@ -381,8 +381,8 @@ impl FromStr for PreciseNumber {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bigdecimal::BigDecimal;
|
||||
use uucore::format::ExtendedBigDecimal;
|
||||
|
||||
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
||||
use crate::number::PreciseNumber;
|
||||
use crate::numberparse::ParseNumberError;
|
||||
|
||||
|
|
|
@ -10,11 +10,10 @@ use clap::{Arg, ArgAction, Command};
|
|||
use num_traits::{ToPrimitive, Zero};
|
||||
|
||||
use uucore::error::{FromIo, UResult};
|
||||
use uucore::format::{num_format, sprintf, Format, FormatArgument};
|
||||
use uucore::format::{num_format, sprintf, ExtendedBigDecimal, Format, FormatArgument};
|
||||
use uucore::{format_usage, help_about, help_usage};
|
||||
|
||||
mod error;
|
||||
mod extendedbigdecimal;
|
||||
mod hexadecimalfloat;
|
||||
|
||||
// public to allow fuzzing
|
||||
|
@ -24,7 +23,6 @@ pub mod number;
|
|||
mod number;
|
||||
mod numberparse;
|
||||
use crate::error::SeqError;
|
||||
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
||||
use crate::number::PreciseNumber;
|
||||
|
||||
const ABOUT: &str = help_about!("seq.md");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# spell-checker:ignore (features) zerocopy
|
||||
# spell-checker:ignore (features) bigdecimal zerocopy
|
||||
|
||||
[package]
|
||||
name = "uucore"
|
||||
|
@ -58,6 +58,8 @@ blake3 = { workspace = true, optional = true }
|
|||
sm3 = { workspace = true, optional = true }
|
||||
crc32fast = { workspace = true, optional = true }
|
||||
regex = { workspace = true, optional = true }
|
||||
bigdecimal = { workspace = true, optional = true }
|
||||
num-traits = { workspace = true, optional = true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
walkdir = { workspace = true, optional = true }
|
||||
|
@ -94,7 +96,7 @@ fs = ["dunce", "libc", "winapi-util", "windows-sys"]
|
|||
fsext = ["libc", "windows-sys"]
|
||||
fsxattr = ["xattr"]
|
||||
lines = []
|
||||
format = ["itertools", "quoting-style"]
|
||||
format = ["bigdecimal", "itertools", "num-traits", "quoting-style"]
|
||||
mode = ["libc"]
|
||||
perms = ["entries", "libc", "walkdir"]
|
||||
buf-copy = []
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore bigdecimal extendedbigdecimal extendedbigint
|
||||
// spell-checker:ignore bigdecimal extendedbigdecimal
|
||||
//! An arbitrary precision float that can also represent infinity, NaN, etc.
|
||||
//!
|
||||
//! The finite values are stored as [`BigDecimal`] instances. Because
|
||||
|
@ -68,7 +68,6 @@ pub enum ExtendedBigDecimal {
|
|||
}
|
||||
|
||||
impl ExtendedBigDecimal {
|
||||
#[cfg(test)]
|
||||
pub fn zero() -> Self {
|
||||
Self::BigDecimal(0.into())
|
||||
}
|
||||
|
@ -197,7 +196,7 @@ mod tests {
|
|||
use bigdecimal::BigDecimal;
|
||||
use num_traits::Zero;
|
||||
|
||||
use crate::extendedbigdecimal::ExtendedBigDecimal;
|
||||
use crate::format::extendedbigdecimal::ExtendedBigDecimal;
|
||||
|
||||
#[test]
|
||||
fn test_addition_infinity() {
|
|
@ -32,12 +32,14 @@
|
|||
|
||||
mod argument;
|
||||
mod escape;
|
||||
pub mod extendedbigdecimal;
|
||||
pub mod human;
|
||||
pub mod num_format;
|
||||
pub mod num_parser;
|
||||
mod spec;
|
||||
|
||||
pub use argument::*;
|
||||
pub use extendedbigdecimal::ExtendedBigDecimal;
|
||||
pub use spec::Spec;
|
||||
use std::{
|
||||
error::Error,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue