Skip to content

#683: use >= 0 for sign selection in badge.xsl to avoid displaying -0#697

Open
morphqdd wants to merge 1 commit into
zerocracy:masterfrom
morphqdd:683-badge-negative-zero
Open

#683: use >= 0 for sign selection in badge.xsl to avoid displaying -0#697
morphqdd wants to merge 1 commit into
zerocracy:masterfrom
morphqdd:683-badge-negative-zero

Conversation

@morphqdd

@morphqdd morphqdd commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Closes #683.

xsl/badge.xsl's sign-selection branch used strict $avg > 0, so when $avg is exactly "0.0"
(zero facts, or a rounded-to-zero average), the condition is false and the otherwise-branch emits
-, while abs($avg) emits 0 — the badge shows -0.

Widened the sign check to $avg >= 0, matching the existing correct pattern already used for
color selection in vitals.xsl ($i >= 0).

Added test_shows_plus_zero_when_average_is_exactly_zero to test/pages/test_badge.rb, which
transforms a minimal <fb/> (zero facts → avg = 0.0) through the real badge.xsl via Saxon and
asserts the rendered text is +0, not -0.

Verified directly with Saxon-HE 9.8.0-5 (downloaded jar): confirmed the badge renders -0 without
the fix and +0 with the fix, for the same zero-average input.

Note: I could not run this new test locally through Minitest — qbash (used by the existing
xslt() test helper and my new test) hardcodes /bin/bash, which doesn't exist on this NixOS
sandbox — but this is an environment artifact unrelated to the change (confirmed via a direct
Saxon invocation outside the test harness, and the real CI test job runs on Ubuntu where
/bin/bash exists).

@morphqdd

morphqdd commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@yegor256, please take a look when you have a moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

badge.xsl displays "-0" when average score is exactly zero

1 participant