Write whole-number doubles with a fraction so they stay floating-point - #90
Merged
Merged
Conversation
…t [patch] A double literal was written with its round-trip text alone, so 2.0 became 2 and 1.0 / 2.0 became integer division in C, C++ and Go and a type error in Rust. Part of #78. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012B4b6sZaZ7tFJzNvax1B89
|
This was referenced Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Part of #78. This is the core fix the triage comment separated out. Non-finite values are still open; see below.
What changed
LanguageGeneratorBase.FormatDouble. It formats with"R"and appends.0when the text has no.,Eoreand the value is finite. The shared literal path inTryGenerateCommonNodenow calls it, which covers C, C++, Go, Rust, Python and JavaScript.1.0 / 2.0is now written as(1.0 / 2.0), where before it was(1 / 2). That was integer division (0) in C, C++ and Go and E0308 in Rust.dsuffix, which makes2da double.FloatingPointLiteralTests:1.0 / 2.0keeps its fractions in all six generators.0.5,-3.25,1E+300,0.1) are written unchanged.Not in this PR (the issue stays open for it)
INFINITY/NAN,f64::INFINITY,math.Inf(1),float('inf'), …). Some of these need an include or import added, so they get their own change. Non-finite values are written the same as before, and.0is not appended to them..inf,-.infand.naninYamlDeserializer.Verification
CGenerator wrote (1 / 2). With it, the test passes.dotnet build: clean. Full suite: 910/910 pass.🤖 Generated with Claude Code
https://claude.ai/code/session_012B4b6sZaZ7tFJzNvax1B89
Generated by Claude Code