In the documentation for the `isLess(than:)` and `isLessThanOrEqualTo(_:)`
methods, a code sample isn't being formatted correctly due to it directly
following an unordered list. This change adds an additional message that
introduces the code sample, separating it from the list and allowing
the correct formatting to be applied.
There isn't actually an ** operator in Swift, so making the formula that
includes ** for exponentiation look like Swift can lead to confusion.
Fixes rdar://56184186
Introduce checking of ConcurrentValue conformances:
- For structs, check that each stored property conforms to ConcurrentValue
- For enums, check that each associated value conforms to ConcurrentValue
- For classes, check that each stored property is immutable and conforms
to ConcurrentValue
Because all of the stored properties / associated values need to be
visible for this check to work, limit ConcurrentValue conformances to
be in the same source file as the type definition.
This checking can be disabled by conforming to a new marker protocol,
UnsafeConcurrentValue, that refines ConcurrentValue.
UnsafeConcurrentValue otherwise his no specific meaning. This allows
both "I know what I'm doing" for types that manage concurrent access
themselves as well as enabling retroactive conformance, both of which
are fundamentally unsafe but also quite necessary.
The bulk of this change ended up being to the standard library, because
all conformances of standard library types to the ConcurrentValue
protocol needed to be sunk down into the standard library so they
would benefit from the checking above. There were numerous little
mistakes in the initial pass through the stsandard library types that
have now been corrected.
* Moved `random` methods out of FloatingPoint.swift
* Added `random` methods to FloatingPointRandom.swift
* Added FloatingPointRandom.swift to CMakeLists.txt
* Added FloatingPointRandom.swift to GroupInfo.json
* Moved filename within CMakeLists.txt
Previously these always went through the FloatingPoint-provided default implementation, which is not particularly efficient. Also try removing inlinable from the generic _convert hooks, since we probably never want to actually inline them.
* Remove doc comments from concrete floating-point types
... when they are already present on the protocol. I don't *think* that we need them anymore for xcode documentation purposes. There are reasonable arguments both ways on this:
1. when you're editing the concrete implementations, it's sometimes nice to have the doc comment right there.
2. but it needlessly repetitive, and introduces the opportunity for comments to get out of sync.
3. it also adds noise; it would be nice for information density if the implementation only had implementation notes.
* Add examples to documentation for FloatingPoint.isCanonical
In particular, document that subnormal encodings are treated as non-canonical zeros on platforms that flush to zero.
* Additional fixes by @xwu and @natecook1000 .
This implements the protocols and static functions proposed in SE-0246, plus some initial test coverage. It also has some rough accompanying cleanup of tgmath. It does not include the globals (on scalars or SIMD types) nor does it deprecate much in tgmath.h.
* Revert "Merge pull request #23791 from compnerd/you-know-nothing-clang"
This reverts commit 5150981150, reversing
changes made to 8fc305c03e.
* Revert "Merge pull request #23780 from compnerd/math-is-terrible"
This reverts commit 2d7fedd25f, reversing
changes made to 0205150b8f.
* Revert "Merge pull request #23140 from stephentyrone/mafs"
This reverts commit 777750dc51, reversing
changes made to 0c8920e747.
This commit implements SE-0246, by adding conformance to Real to the Float, CGFloat, Double, and Float80 types, implemented either in terms of the system's C math library, existing standard library functionality, or LLVM intrinsics. It includes basic test coverage for these new functions, and deprecates and obsoletes *some* existing functionality in the Platform overlay. We still need to make a decision about how to handle the remaining "tgmath" functions, because obsoleting them is technically a source-breaking change (if users have unqualified names like "exp(1)", it's fine, but it would break users who have used qualified names like "Darwin.exp(1)".)
This can map straight to the LLVM copysign intrinsic for builtin types, which both gets us better codgen and lets the compiler plug this operation into other LLVM-level optimizations.
1. Move discussion of `DBL_EPSILON` etc. onto `ulpOfOne` instead of `ulp`.
2. Add text explaining that `ulpOfOne` is a poor value to use for approximate comparison.
These should be audited since some might not actually need to be
@inlinable, but for now:
- Anything public and @inline(__always) is now also @inlinable
- Anything @usableFromInline and @inline(__always) is now @inlinable
Also removes .gyb from FloatingPoint.swift, since we barely are using it after this change.
Rework Self._convert from integer, by making it require RawSignificand: FixedWidthInteger. This requirement should have always been there, and the existing implementaiton wouldn't have actually worked correctly without it. Making it explcit makes the implementation quite a bit simpler, which is nice.
Additionally add a fast-path conversion that will catch all concrete integer types without needing to be a concrete implementation itself. Room for further improvement, but good start. See RandomDouble performance improvements, for example.