This is an archive of the discontinued LLVM Phabricator instance.

[libc] add rounding modes to printf float conv
ClosedPublic

Authored by michaelrj on Jul 13 2022, 4:01 PM.

Details

Summary

This adds functionality for rounding towards negative inf, positive inf,
and zero to the float hex conversion (%a).

Diff Detail

Event Timeline

michaelrj created this revision.Jul 13 2022, 4:01 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 13 2022, 4:01 PM
michaelrj requested review of this revision.Jul 13 2022, 4:01 PM
lntue added inline comments.Jul 13 2022, 7:06 PM
libc/test/src/stdio/sprintf_test.cpp
716

It is better to use ForceRoundingMode that was refactored in https://reviews.llvm.org/D129685. You can do something like:

{
  ForceRoundingMode r(RoundingMode::Nearest);

  <tests>
}

without worrying about changing current / default rounding modes.

michaelrj updated this revision to Diff 444842.Jul 14 2022, 4:41 PM
michaelrj marked an inline comment as done.

move to using ForceRoundingMode for rounding mode testing.

lntue accepted this revision.Jul 15 2022, 5:20 AM
This revision is now accepted and ready to land.Jul 15 2022, 5:20 AM

fix formatting

This revision was landed with ongoing or failed builds.Jul 15 2022, 11:11 AM
This revision was automatically updated to reflect the committed changes.