[libc-commits] [PATCH] D157535: [libc] Fix printf %f bugs

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Aug 14 22:04:02 PDT 2023


sivachandra accepted this revision.
sivachandra added a comment.
This revision is now accepted and ready to land.

LGTM but I have left a question on a comment in the test.



================
Comment at: libc/test/src/stdio/sprintf_test.cpp:1297
+  // The number continues after the literal because floating point numbers don't
+  // represent a specific value, but a range of values. The number provided as
+  // the literal and the number printed are both in the range for the value
----------------
I am confused with this wording. My knowledge says that if you write down a literal, then is already an exact value (of course, might not correspond exactly to an encoded value). Likewise, if a floating number is encoded as single/double/quad precision number, then that is also an exact number.


================
Comment at: libc/test/src/stdio/sprintf_test.cpp:1303
+      "000000000000000000000000000000000000000000000000000000000000000000000001"
+      "131959884853339045938639911360973972585316399767392273697826861241937664"
+      "824105639342441431495119762431744054912109728706985341609159156917030486"
----------------
sivachandra wrote:
> Nit: Add a comment explaining why there are digits beyond the `3339` even though the literal above does not.
Isn't the reason that the closest number that can be represented as a double precision number to that literal?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157535/new/

https://reviews.llvm.org/D157535



More information about the libc-commits mailing list