Skip to content

Conversation

@natecook1000
Copy link
Member

@natecook1000 natecook1000 commented Sep 8, 2025

Adds parsers for the standard library floating point types with endianness specifiers. Resolves #25.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've run Scripts/format.sh to correctly format my change
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@natecook1000 natecook1000 force-pushed the floating-point-parsers branch 10 times, most recently from cbd8d89 to dc08d17 Compare September 9, 2025 21:21
@natecook1000 natecook1000 force-pushed the floating-point-parsers branch from dc08d17 to 1382651 Compare September 9, 2025 21:35
@natecook1000
Copy link
Member Author

The API documentation is good for now – I'll follow up with DocC curation for these, the LEB parsers, and other APIs we add before the next release.

@natecook1000 natecook1000 marked this pull request as ready for review September 10, 2025 16:36
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//

Copy link
Member

@stephentyrone stephentyrone Sep 18, 2025

Choose a reason for hiding this comment

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

This needs to be #if'd out on macOS/Intel.

#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
extension Float16 {
  // ...
}
#endif

Copy link
Member

Choose a reason for hiding this comment

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

We may want to provide a Float(parsingFloat16:) as a workaround for macOS/Intel systems, but that can be a follow-on PR.

//#else
//public struct Float80: Sendable, Equatable {
// init(sign: FloatingPointSign, exponentBitPattern: UInt, significandBitPattern: UInt64) {}
//}
Copy link
Member

Choose a reason for hiding this comment

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

As with Float16, if anything what I would provide here is a fallback bailable parser that tries to parse the Float80 into a Double (what to do for out-of-range values TBD).

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.

Feature request: Floating point parsing

3 participants