Skip to content

Exceeding representation range and spewing junk for extremal powers #114

@eyalroz

Description

@eyalroz

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"

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingresolved-on-developA changeset fixing this issue has been commiutted to the development branch

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions