Skip to content

Fix serialization of zero decimal values in IEEE754 mode - #881

Merged
27pchrisl merged 2 commits into
flat3:5.xfrom
AndreasMueck:fix/decimal-zero-serialization
Sep 16, 2026
Merged

27pchrisl merged 2 commits into
flat3:5.xfrom
AndreasMueck:fix/decimal-zero-serialization

Conversation

@AndreasMueck

Copy link
Copy Markdown
Contributor

Summary

Fixes serialization of finite zero Edm.Decimal values when
IEEE754Compatible=true.

Previously, toJsonIeee754() evaluated log10(0.0), which resulted in an
infinite precision passed to sprintf() and caused an HTTP 500 response.

This change:

  • returns "0" for zero decimal values;
  • uses abs() for the precision calculation, avoiding log10() errors for
    negative finite decimals.

Reproduction

Persist an Edm.Decimal value of 0.00 and request it using:

Accept: application/json;IEEE754Compatible=true

Before this change, the response fails with:

The float INF is not representable as an int, cast occurred

Added a regression test for Decimal(0.0) in IEEE754 mode.

Verified with:

./vendor/bin/phpunit --filter test_decimal_zero_serializes_in_ieee754_mode

@27pchrisl
27pchrisl merged commit b742ba4 into flat3:5.x Sep 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants