Skip to content
Closed
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
11 changes: 9 additions & 2 deletions src/libcore/fmt/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use fmt::{Formatter, Result, LowerExp, UpperExp, Display, Debug};
use fmt::{Formatter, Result, LowerExp, UpperExp, Display, Debug, Binary};
use mem;
use num::flt2dec;
use num::{flt2dec, Float};

// Don't inline this so callers don't use the stack space this function
// requires unless they have to.
Expand Down Expand Up @@ -150,6 +150,13 @@ macro_rules! floating {
float_to_exponential_common(fmt, self, true)
}
}

#[stable(feature = "floating_point_binary_fmt", since = "1.26.0")]
impl Binary for $ty {
fn fmt(&self, fmt: &mut Formatter) -> Result {
write!(fmt, "{:01$b}", self.to_bits(), 8 * mem::size_of::<$ty>())
}
}
)
}

Expand Down