apple / apple/swift-numerics

Feature request: GCD for floating-point

Open
#279 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
1.9k
Forks
181
Avg merge
2d 5h
Merged PRs (30d)
6

Description

Surprisingly, I can't find _any_ implementation of floating-point GCD for Swift, anywhere.

While there are implementations in other languages - Python has heaps - a lot of them gloss over the important detail of rounding. And for those that don't, porting them to Swift too literally may introduce mathematical errors, depending on how the source language differs from Swift in its handling of reals.

Since this library already has a good GCD implementation for integers (which seems to be a prerequisite for a floating-point variant), perhaps it'd make sense to add a version for `FloatingPoint`?

Contributor guide

Open the contributing guide

Research direction

Start by reading the library’s existing integer GCD implementation and the issue discussion about rounding and Swift’s handling of reals. Define the expected behavior for a FloatingPoint GCD, then validate the chosen semantics against representative rounding cases; done means the new variant is implemented with coverage for those cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.