Skip to content

Conversation

@tbkka
Copy link
Contributor

@tbkka tbkka commented Jul 2, 2025

This replaces the previous SwiftDtoa.cpp with the same algorithm reimplemented in Swift. It supports Float16, Float32, Float64, and Float80 (on Intel).

Performance is reasonable: In my testing (M1 and x86_64): Float16 and Float32 are a bit faster than the C version, Float64 is almost exactly the same, Float80 is a bit slower.

I think I've finally worked out the availability, though I'd appreciate someone who knows better taking a critical look.

@tbkka
Copy link
Contributor Author

tbkka commented Jul 2, 2025

CC: @stephentyrone for visibility. (I'll eventually need advice about how to deal with the availability mess here.)

@tbkka tbkka force-pushed the tbkka-swift-floatingpointtostring branch from 295114c to 28ca1f0 Compare July 29, 2025 19:50
@rauhul rauhul moved this to In Progress in Embedded Swift Aug 1, 2025
@tbkka tbkka force-pushed the tbkka-swift-floatingpointtostring branch from 28ca1f0 to 5bfe1c1 Compare August 1, 2025 22:04
@tbkka tbkka marked this pull request as ready for review August 1, 2025 23:13
Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be missing the addition of the new file to swiftCore in the new runtimes build.

@tbkka
Copy link
Contributor Author

tbkka commented Aug 4, 2025

This seems to be missing the addition of the new file to swiftCore in the new runtimes build.

How do I fix that? I'm not familiar with "the new runtimes build."

@etcwilde
Copy link
Member

etcwilde commented Aug 4, 2025

How do I fix that? I'm not familiar with "the new runtimes build."

Add FloatingPointToString.swift to Runtimes/Core/core/CMakeLists.txt

FloatingPoint.swift

@tbkka tbkka force-pushed the tbkka-swift-floatingpointtostring branch from 5b20b0b to cac5983 Compare August 4, 2025 19:08
@tbkka
Copy link
Contributor Author

tbkka commented Aug 4, 2025

@swift-ci Please test

1 similar comment
@tbkka
Copy link
Contributor Author

tbkka commented Aug 4, 2025

@swift-ci Please test

@tbkka
Copy link
Contributor Author

tbkka commented Aug 4, 2025

@etcwilde Now we're failing in CI for AVR. Clearly, a 16-bit platform does not want this file. How do I exclude it from those?

@tbkka
Copy link
Contributor Author

tbkka commented Aug 5, 2025

@swift-ci Please test

@tbkka
Copy link
Contributor Author

tbkka commented Aug 5, 2025

I tweaked one place where 32-bit int was assumed but not specified. This may let it build on AVR.

For example, this avoids the need to do any explicit byte-by-byte
writes when expanding "123" out to "123000000.0".

This also required reworking the "back out extra digits" process
for Float64 to ensure the unused digits get written as '0' characters
instead of null bytes.
@tbkka tbkka force-pushed the tbkka-swift-floatingpointtostring branch from 77b26ca to 7a4bd46 Compare September 23, 2025 15:08
@tbkka
Copy link
Contributor Author

tbkka commented Sep 23, 2025

@swift-ci Please test macOS Platform

@tbkka
Copy link
Contributor Author

tbkka commented Sep 23, 2025

Huh... CI checked everything out, then just ... stopped. After an hour, the script timed out with an error.

@tbkka
Copy link
Contributor Author

tbkka commented Sep 23, 2025

@swift-ci Please test macOS platform

@tbkka
Copy link
Contributor Author

tbkka commented Sep 23, 2025

@swift-ci Please test macOS platform

@tbkka
Copy link
Contributor Author

tbkka commented Sep 24, 2025

@swift-ci Please test macOS platform

@tbkka
Copy link
Contributor Author

tbkka commented Sep 24, 2025

@swift-ci Please test macOS Platform

@tbkka
Copy link
Contributor Author

tbkka commented Sep 24, 2025

@swift-ci Please test macOS Platform

@tbkka
Copy link
Contributor Author

tbkka commented Sep 25, 2025

@swift-ci Please test Linux platform

@tbkka
Copy link
Contributor Author

tbkka commented Sep 26, 2025

@swift-ci Please test Windows Platform

@tbkka tbkka merged commit 54627fb into swiftlang:main Sep 29, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Embedded Swift Sep 29, 2025
tbkka added a commit to tbkka/swift that referenced this pull request Sep 29, 2025
…atingpointtostring"

This reverts commit 54627fb, reversing
changes made to dda4608.
tbkka added a commit that referenced this pull request Sep 30, 2025
…ption

Revert "Merge pull request #82750 from tbkka/tbkka-swift-floatingpointtostring"
tbkka added a commit that referenced this pull request Oct 13, 2025
…tion in Swift.

This reverts PR #84576, which was a revert of PR #82750
It reverts commit 4ac18aa, reversing
changes made to b46eddb.
dendiz pushed a commit to dendiz/swift that referenced this pull request Oct 21, 2025
…mplementation in Swift.

This reverts PR swiftlang#84576, which was a revert of PR swiftlang#82750
It reverts commit 4ac18aa, reversing
changes made to b46eddb.
speednoisemovement pushed a commit to speednoisemovement/swift that referenced this pull request Oct 29, 2025
…mplementation in Swift.

This reverts PR swiftlang#84576, which was a revert of PR swiftlang#82750
It reverts commit 4ac18aa, reversing
changes made to b46eddb.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

10 participants