dtolnay / ryu

Fast floating point to string conversion
Apache License 2.0
606 stars 27 forks source link

Ryu format 3.2 as 0.0 on powerpc64le #47

Closed NobodyXu closed 2 years ago

NobodyXu commented 2 years ago

In my PR https://github.com/ParkMyCar/compact_str/pull/16 , when formatting 3.2 using ryu (currently disabled due to bug), it gives me 0.0 on target powerpc64le instead of 3.2 (it works on all other target).

P.S. formatting using std on the target gives me 0

dtolnay commented 2 years ago

If std::fmt is formatting it as 0 as well, I would propose that this is unlikely to be a bug in this crate.

Once whatever is broken in std or rustc has been fixed, if ryu is still incorrect after that, please follow up.

NobodyXu commented 2 years ago

Sure.

NobodyXu commented 2 years ago

@dtolnay Please reopen this as the nightly rustc has fixed the error formatting 3.2_f32 as 0.0, but ryu still format it as 0.0 according to this CI log, though it can format f64 correctly.

dtolnay commented 2 years ago

What was the fix?

NobodyXu commented 2 years ago

What was the fix?

We didn't fix the code, somehow after updating nightly, the bug is fixed, but ryu still format 3.2_f32 as 0.0, but format the f64 correctly.

I also discovered a minor bug in std format, f32::NEG_INFINITY is formatted as "inf" instead of "-inf".

dtolnay commented 2 years ago

If it randomly goes away without any relevant code changes in std's formatting code, I am still extremely skeptical that it would need a code change in ryu's formatting code as opposed to the bug being elsewhere.

NobodyXu commented 2 years ago

If it randomly goes away without any relevant code changes in std's formatting code, I am still extremely skeptical that it would need a code change in ryu's formatting code as opposed to the bug being elsewhere.

Yeah, it looks like a bug in generating the assembly in rustc or llvm.