http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48906
--- Comment #28 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-06-06 12:41:55 UTC --- I had a look at the code and what I think we should do is the following: If G editing and a scale factor p != 0 is in effect, split the rounding step into 2 steps: First, check if overflow occurs (.9999.. => 1.0000...) but do not actually overwrite the digits yet. With this information, we determine the final value of e. If it turns out we need F editing: Repeat the rounding as above (or remember if overflow occured the first time), and this time actually overwrite the digits. If it turns out we need E editing: Set the new value for the number of digits according to p and repeat the rounding. It may help to refactor some of the code into a separate function, since we need to call it twice.