On lundi 6 septembre 2021 06 h 59 min 40 s EDT Martin Storsj? wrote: > On Sun, 5 Sep 2021, Patrick Northon via Mingw-w64-public wrote: > > Hi, here's a patch to fix another problem with formatting long doubles in > > > hexadecimal. I found a failing case with a denormalized value: > Thanks for the patch and testcase! > > Git didn't manage to automatically apply your patch and neither did > patch(1), but after applying it manually, I could confirm that it fixes > the problem. > > (The patch had a bit funky indentation in a few places where the source > uses tabs - I see that your editor treats tabs as 4 spaces, while the > source is written to have them equal 8 spaces. I sent a patch to expand > the tabs to spaces in the whole file, to make it easier to work on for > everybody.) > > > But I feel a little uneasy about the patch - why would we unconditionally > do a "value.__pformat_fpreg_exponent -= 3;" at the start of > __pformat_emit_xfloat? I don't see the corresponding adjustment in > __pformat_xldouble for cases where the exponent originally is nonzero > (where we just do "z.__pformat_fpreg_exponent -= 0x3FFF;"). I do see that > it does work as normal floats do get printed correctly though. > > Can the handling be confined to a codepath specifically for denormals > somewhere? > > // Martin
Yes the indentation is funky because the original has one level with a tab character and spaces for the rest in some parts. I see you have submitted a patch to fix this. The adjustment is expected in all cases except a true zero, which is why I set the exponent to 3 in __pformat_xldouble in that case. Beforehand, only in 2 cases would it not adjust the exponent by 3: for a true zero or an unnormal value with unlimited precision. In the later case, afaik, these are invalid values since 1987. It is adjusted by 3 because the leading digit emitted is a 4 bits digits, while the leading digit in a long double is 1 bit, so we have to adjust the exponent. In my next patch for doubles, I will be able to reuse __pformat_emit_xfloat as is and as originally intended, as a generic function to emit a floating- points. _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
