这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dtoa-short"
version = "0.3.0"
version = "0.3.1"
authors = ["Xidorn Quan <me@upsuper.org>"]

description = "Serialize float number and truncate to certain precision"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn write_with_prec<W, V>(dest: &mut W, value: V, prec: usize)

fn restrict_prec(buf: &mut [u8], prec: usize) -> (&[u8], Notation) {
let len = buf.len();
debug_assert!(len <= BUFFER_SIZE, "dtoa may have changed its buffer size");
debug_assert!(len <= BUFFER_SIZE + 1, "dtoa may have changed its buffer size");
// Put a leading zero to capture any carry.
debug_assert!(buf[0] == b'\0', "Caller must prepare an empty byte for us");
buf[0] = b'0';
Expand Down
2 changes: 2 additions & 0 deletions tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,6 @@ fn exponent_part_handling() {
assert_expected_serialization(-9.999999e30_f32, "-10e30");
assert_expected_serialization(9.999999e-30_f32, "10e-30");
assert_expected_serialization(-9.999999e-30_f32, "-10e-30");
// Regression test for assertion failure (https://bugzilla.mozilla.org/show_bug.cgi?id=1402419)
assert_expected_serialization(-8192e17_f32, "-819200000000000000000");
}