Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceeding representation range and spewing junk for extremal powers #114

Closed
eyalroz opened this issue Feb 5, 2022 · 0 comments
Closed
Assignees
Labels
bug Something isn't working resolved-on-develop A changeset fixing this issue has been commiutted to the development branch

Comments

@eyalroz
Copy link
Owner

eyalroz commented Feb 5, 2022

One of our test suite checks is:

  PRINTING_CHECK("-1.23e-308",       ==, sprintf_, buffer, "%.3g", -1.2345e-308);

we used not to get errors for this one... but that was before I refactored the log10 and pow10 computations... we used to get -307, incorrectly; and when it's 308, the pow10 computation exceeds the representable range of doubles, yielding infinity. This propagates along our code and results of all sorts of strange behavior when normalizing the number for printing; finally, we get a buffer of junk:

/home/eyalroz/src/mine/printf/test/test_suite.cpp:1017: FAILED:
  CHECK( !strcmp(buffer, "1.2345678901e-308") )
with expansion:
  false
with messages:
  sprintf_ arguments, replicated ( "arg := arg" ):
  ----
  "%.10e" := "%.10e"
  1.2345678901e-308 := 0.0
  ----
  Resulting buffer contents: "1.2345681837e-308"
@eyalroz eyalroz added the bug Something isn't working label Feb 5, 2022
@eyalroz eyalroz self-assigned this Feb 5, 2022
eyalroz added a commit that referenced this issue Feb 5, 2022
* Special-casing the power-of-10 function for 10^308 and 10^-308.
* Special-casing `get_normalized_components()` to not strive for better precision for near-extremal powers and settle for the "rougher" way to obtain the integral and decimal parts.
* Added a test-case of a near-extremal-power which fails due to the re-normalization even if the powering is correct.
eyalroz added a commit that referenced this issue Feb 5, 2022
* Special-casing the power-of-10 function for 10^308 and 10^-308.
* Special-casing `get_normalized_components()` to not strive for better precision for near-extremal powers and settle for the "rougher" way to obtain the integral and decimal parts.
* Added a test-case of a near-extremal-power which fails due to the re-normalization even if the powering is correct.
eyalroz added a commit that referenced this issue Feb 6, 2022
* Special-casing the power-of-10 function for 10^308 and 10^-308.
* Special-casing `get_normalized_components()` to not strive for better precision for near-extremal powers and settle for the "rougher" way to obtain the integral and decimal parts.
* Added a test-case of a near-extremal-power which fails due to the re-normalization even if the powering is correct.
eyalroz added a commit that referenced this issue Feb 7, 2022
…epresentation range.

* Special-casing the power-of-10 function for 10^-308.
* Altered `get_normalized_components()` to not strive for better precision for near-extremal powers (at both ends) and settle for the "rougher" way to obtain the integral and decimal parts.
* Added a test-case of a near-extremal-power which fails due to the re-normalization even if the powering is correct.
eyalroz added a commit that referenced this issue Feb 7, 2022
…epresentation range.

* Special-casing the power-of-10 function for 10^-308.
* Altered `get_normalized_components()` to not strive for better precision for near-extremal powers (at both ends) and settle for the "rougher" way to obtain the integral and decimal parts.
* Added a test-case of a near-extremal-power which fails due to the re-normalization even if the powering is correct.
eyalroz added a commit that referenced this issue Feb 7, 2022
…epresentation range.

* Special-casing the power-of-10 function for 10^-308.
* Altered `get_normalized_components()` to not strive for better precision for near-extremal powers (at both ends) and settle for the "rougher" way to obtain the integral and decimal parts.
* Added a test-case of a near-extremal-power which fails due to the re-normalization even if the powering is correct.
eyalroz added a commit that referenced this issue Feb 10, 2022
…epresentation range.

* Special-casing the power-of-10 function for 10^-308.
* Altered `get_normalized_components()` to not strive for better precision for near-extremal powers (at both ends) and settle for the "rougher" way to obtain the integral and decimal parts.
* Added a test-case of a near-extremal-power which fails due to the re-normalization even if the powering is correct.
eyalroz added a commit that referenced this issue Feb 11, 2022
…epresentation range.

* Special-casing the power-of-10 function for 10^-308.
* Altered `get_normalized_components()` to not strive for better precision for near-extremal powers (at both ends) and settle for the "rougher" way to obtain the integral and decimal parts.
* Added a test-case of a near-extremal-power which fails due to the re-normalization even if the powering is correct.
@eyalroz eyalroz added the resolved-on-develop A changeset fixing this issue has been commiutted to the development branch label Feb 20, 2022
kuba2k2 pushed a commit to libretiny-eu/library-printf that referenced this issue Feb 25, 2023
* Added a couple of test cases for exposing the behavior of the `#` modifier (alternative mode) together with `ll` (long long modifier), and specifically exposing the example format string mentioned in bug eyalroz#114.
* Our fix for eyalroz#109 was too eager to keep `FLAG_HASH` - it dropped it only when a precision wasn't specified. We're now going part of the way back - dropping `FLAG_HASH` even when precision wasn't specific - except for octal.
* The `long long` version of ntoa now behaves just like the `long` version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved-on-develop A changeset fixing this issue has been commiutted to the development branch
Projects
None yet
Development

No branches or pull requests

1 participant