mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Fix nan sign bug in cformat
This commit is contained in:
1 parent
213a335bcf
commit
31d662eded
1 file changed
+4
-3
+4
-3
@@ -294,11 +294,12 @@ impl CFormatSpec {
|
||||
}
|
||||
|
||||
pub(crate) fn format_float(&self, num: f64) -> String {
|
||||
let sign_string = if num.is_sign_positive() {
|
||||
self.flags.sign_string()
|
||||
} else {
|
||||
let sign_string = if num.is_sign_negative() && !num.is_nan() {
|
||||
"-"
|
||||
} else {
|
||||
self.flags.sign_string()
|
||||
};
|
||||
|
||||
let precision = match self.precision {
|
||||
Some(CFormatQuantity::Amount(p)) => p,
|
||||
_ => 6,
|
||||
|
||||
Reference in new issue
Block a user