Closed
Description
Here's a minimal example which results in a runtime error:
fn main() {
println!("{:.0}", 9.9);
}
I'd expect that format string to work (precision=0, so no digits after the decimal point), but here's what I get with RUST_BACKTRACE=1:
thread '<main>' panicked at 'arithmetic operation overflowed', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/fmt/float.rs:245
stack backtrace:
1: 0x7f92f7b9381f - sys::backtrace::write::h2f046b875b210aadOBA
2: 0x7f92f7b97db2 - panicking::on_panic::h792ac47fb8c07faehHJ
3: 0x7f92f7b8dd6a - rt::unwind::begin_unwind_inner::hbffac672008352c8knJ
4: 0x7f92f7b8e481 - rt::unwind::begin_unwind_fmt::hbe64affaa986f482VlJ
5: 0x7f92f7b976d7 - rust_begin_unwind
6: 0x7f92f7bc1f64 - panicking::panic_fmt::h81cd96819f02da8dIZs
7: 0x7f92f7bc1e8d - panicking::panic::h8ea414638b29b322UXs
8: 0x7f92f7bc6066 - fmt::f64.Display::fmt::hb0a5033b26a63c76UzD
9: 0x7f92f7bc5071 - fmt::write::h3770d88fab3d43d6YXC
10: 0x7f92f7bc4d78 - fmt::Arguments<'a>.Debug::fmt::h542db8d18a17ace0xVC
11: 0x7f92f7bc5110 - fmt::write::h3770d88fab3d43d6YXC
12: 0x7f92f7b9130c - old_io::Writer::write_fmt::h7179537900110901984
13: 0x7f92f7b92275 - old_io::stdio::println_args::hee7144bbc1e28d79dNg
14: 0x7f92f7b8d6e8 - main::h35109694ee10d661eaa
15: 0x7f92f7b9c1c8 - rust_try_inner
16: 0x7f92f7b9c1b5 - rust_try
17: 0x7f92f7b9978c - rt::lang_start::h3d4a7f7be4f6d99bxBJ
18: 0x7f92f7b8d74e - main
19: 0x7f92f6d7dec4 - __libc_start_main
20: 0x7f92f7b8d4f8 - <unknown>
21: 0x0 - <unknown>
Ubuntu 14.10 / 64-bit
rustc 1.0.0-nightly (b0746ff 2015-03-05) (built 2015-03-06)
binary: rustc
commit-hash: b0746ff
commit-date: 2015-03-05
build-date: 2015-03-06
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly