Commit Graph

17 Commits

Author SHA1 Message Date
Xiaodi Wu
03903ae1ea [stdlib] Fix generic floating-point conversion when two representable values are equally close 2020-03-03 18:22:47 -05:00
Stephen Canon
fb2128b33b Remove doc comments from concrete floating-point types (#26399)
* 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 .
2019-08-06 18:17:37 -04:00
Xiaodi Wu
a078c33ceb [stdlib] Change documented behavior of FloatingPoint.significand (#26390) 2019-07-29 11:08:04 -04:00
Paul Hudson
06f82a53b5 Replaced the majority of ' : ' with ': '. 2019-07-18 20:46:07 +01:00
Stephen Canon
166d0fa961 FloatingPoint.radix should be transparent. (#25789)
* FloatingPoint.radix should be inlinable.

* Switch transparent to inlinable+inline(__always).
2019-06-26 18:20:27 -04:00
Vlad Gorlov
6370681656 Android cross-compile on macOS: Fix for compile error addressed Float80 data type. (#25502)
* Fixes issue addressed Float80 data type. Float80 is disabled for Intel architectures (i.e. Android Simulator).

* More precise condition check.
2019-06-17 13:40:44 -04:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Stephen Canon
57a4553832 SE-0246: Protocols and static functions (#23824)
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.
2019-04-17 23:57:33 +02:00
Stephen Canon
c5e3f85378 Revert SE-0246 (#23800)
* 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.
2019-04-04 19:35:25 -04:00
Steve (Numerics) Canon
3fda509805 Implementation of ElementaryFunctions / Real protocols.
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)".)
2019-04-02 18:49:31 -04:00
Stephen Canon
60fc39e72a Improve codegen for init(signOf: magnitudeOf:) (#23727)
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.
2019-04-02 09:49:18 -04:00
Stephen Canon
20a1781842 Minor improvement for the documentation of ulp and ulpOfOne. (#23211)
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.
2019-03-11 13:06:41 -04:00
Karoy Lorentey
545fa5e640 [stdlib] Re-add previously synthesized hashing definitions 2018-11-22 17:15:36 +00:00
Maxim Moiseev
cbf83ac04f [NFC][stdlib] Add FIXME markers to simplify audit 2018-11-14 11:58:42 -08:00
Slava Pestov
f6c2caf64b stdlib: Add @inlinable to @inline(__always) declarations
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
2018-11-13 15:15:07 -05:00
Maxim Moiseev
a54c53580c [stdlib] Audit use of @_transparent in FP code
<rdar://problem/45140678>
2018-10-10 17:00:39 -07:00
Stephen Canon
0707ca6dac Remove concrete floating-point inits from integer types (#19624)
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.
2018-09-30 11:57:49 -04:00