File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -232,12 +232,19 @@ impl fmt::Display for Mpf {
232232impl fmt:: Debug for Mpf {
233233 /// Due to the way `Mpf::get_str` works, the output contains an implicit
234234 /// radix point to the left of the first digit. `3.14`, for instance, will
235- /// print as `314e1` which means ` 0.314e1`.
235+ /// print as `0.314e1`.
236236 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
237237 let mut exp: c_long = 0 ;
238238 match self . get_str ( 0 , 10 , & mut exp) {
239239 ref n if n. len ( ) == 0 => write ! ( f, "0" ) ,
240- n => write ! ( f, "{}e{}" , n, exp)
240+ n => {
241+ if self . sign ( ) == Sign :: Negative {
242+ // Skip sign output
243+ write ! ( f, "-0.{}e{}" , & n[ 1 ..] , exp)
244+ } else {
245+ write ! ( f, "0.{}e{}" , n, exp)
246+ }
247+ }
241248 }
242249 }
243250}
Original file line number Diff line number Diff line change @@ -727,7 +727,7 @@ mod mpf {
727727 // digit. The applicable exponent is written through the expptr pointer.
728728 // For example, the number 3.1416 would be returned as string "31416"
729729 // and exponent 1."
730- assert_eq ! ( format!( "{:?}" , pi) , "3141592653589e1" ) ;
731- assert_eq ! ( format!( "{:?}" , -& pi) , "-3141592653589e1" ) ;
730+ assert_eq ! ( format!( "{:?}" , pi) , "0. 3141592653589e1" ) ;
731+ assert_eq ! ( format!( "{:?}" , -& pi) , "-0. 3141592653589e1" ) ;
732732 }
733733}
You can’t perform that action at this time.
0 commit comments