Skip to content

Commit 03d2449

Browse files
committed
fix: increase precision of LN_ constants
1 parent 80881ac commit 03d2449

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,14 @@ const UNITS_IEC: &str = "KMGTPE";
6565

6666
/// SI (decimal) units.
6767
///
68-
///
6968
/// See <https://en.wikipedia.org/wiki/Kilobyte>.
7069
const UNITS_SI: &str = "kMGTPE";
7170

7271
/// `ln(1024) ~= 6.931`
73-
const LN_KIB: f64 = 6.931471806;
72+
const LN_KIB: f64 = 6.931_471_805_599_453;
7473

7574
/// `ln(1000) ~= 6.908`
76-
const LN_KB: f64 = 6.907755279;
75+
const LN_KB: f64 = 6.907_755_278_982_137;
7776

7877
#[derive(Debug, Clone, Default)]
7978
pub enum Format {
@@ -471,7 +470,7 @@ mod tests {
471470
assert_to_string("293.9 KiB", ByteSize::kb(301), Format::IEC);
472471
assert_to_string("301.0 kB", ByteSize::kb(301), Format::SI);
473472

474-
assert_to_string("1024.0 KiB", ByteSize::mib(1), Format::IEC);
473+
assert_to_string("1.0 MiB", ByteSize::mib(1), Format::IEC);
475474
assert_to_string("1.0 MB", ByteSize::mib(1), Format::SI);
476475

477476
assert_to_string("1.9 GiB", ByteSize::mib(1907), Format::IEC);

0 commit comments

Comments
 (0)