Commit Graph

80 Commits

Author SHA1 Message Date
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Nate Cook
bd6025f463 [stdlib] Various documentation fixes
- Fix incorrect type in Float(_:String) examples
- Expand discussions for ExpressibleBy_Literal protocols
- Add notes about non-escaping unsafe pointers from closures
- Add note about isEmpty to Collection.count discussions
- Describe imported `Bool` types
- Clean up some floating point discussions
- Provide some additional operator documentation
- Revise documentation for CVarArg functions
- Fix incorrect Set method parameter descriptions
- Clarify array bridging behavior
- Add collection subscript complexity notes
2016-11-11 11:23:49 -06:00
Maxim Moiseev
70cf3633b5 Fixing the FloatingPoint.subtracting doc comment (#5581) 2016-11-01 20:13:08 -05:00
practicalswift
cc852042c9 [gardening] Fix accidental trailing whitespace. 2016-10-29 10:22:58 +02:00
Steve (Numerics) Canon
40628dd043 Fix for documentation of the [form]TruncatingRemainder methods.
The result of these methods was incorrectly documented as having
the same sign as `other` (the divisor) rather than `self` (the
dividend). This patch corrects the documentation, and also fixes
the capitalization of `formTruncatingRemainder` in one location.
2016-09-28 12:20:23 -04:00
Max Moiseev
a779f3059d [stdlib] availability attributes for floating point types 2016-09-23 16:42:17 -07:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Nate Cook
29c9c61f03 [stdlib] Revise and expand floating-point documentation 2016-07-31 10:14:06 -05:00
Dmitri Gribenko
e4e9cf5cac Merge pull request #3683 from stephentyrone/totally-ordered-label
Bugfix: argument label of isTotallyOrdered.
2016-07-24 00:05:25 -07:00
Patrick Pijnappel
2728bd0145 [stdlib] Standardize function signature spacing 2016-07-23 11:51:32 +10:00
Steve (Numerics) Canon
11baa7a14f Possible fix for label of isTotallyOrdered(below:). 2016-07-22 15:21:21 -04:00
Stephen Canon
cc024d0710 Generic implementations of math functions implementable on FloatingPoint. (#3524)
Replace the non-generic tgmath functions with generic <T: FloatingPoint> implementations where possible, and move the global sqrt() operation into tgmath.
2016-07-15 08:19:08 -04:00
Maxim Moiseev
61d1c599e8 [stdlib] Introducing the new Arithmetic protocol (#3479)
* [stdlib] Introducing the new Arithmetic protocol

* [stdlib] conforming floating point types to the new Arithmetic protocol

* [stdlib] removing AbsoluteValuable conformance from floating point types

* [stdlib] removing the integers prototype
2016-07-13 11:35:14 -07:00
Robert Widmann
f97e5dcb0e [SE-0115][1/2] Rename *LiteralConvertible protocols to ExpressibleBy*Literal. This
change includes both the necessary protocol updates and the deprecation
warnings
suitable for migration.  A future patch will remove the renamings and
make this
a hard error.
2016-07-12 15:25:24 -07:00
Stephen Canon
9c08fbf4ed SE-0113 + residual SE-0067 work (#3443)
Implemented SE-0113 + residual SE-0067 operations.

- adds `rounded` and `round` to `FloatingPoint`, from SE-0113.
- adds `remainder`, `squareRoot`, and `addingProduct`, from SE-0067.
- adds basic test coverage for all of the above.
- provides a default implementation of `nextDown` on `FloatingPoint`.
2016-07-11 09:38:25 -04:00
Stephen Canon
5f47048491 Fix sNaN behavior of .minimum, .maximum, .minimumMagnitude and .maximumMagnitude. (#3361)
* Bring the behavior of Self.minimum, .maximum, .minimumMagnitude and .maximumMagnitude in line with the IEEE 754 rules.

Specifically, if either argument is a signaling NaN, the result should be a quiet NaN.  Previously, signaling NaN inputs were treated identically to quiet NaN inputs.

Some other changes folded in with this:
- Formally define which argument is returned if lhs == rhs or abs(lhs) == abs(rhs) in the case of the Magnitude versions.  This guarantees that the set {min,max} is identitical to the set {lhs,rhs} so long as neither argument is NaN.  This is not only a nod to formalism; it's also a critical property for generic head-tail arithmetic to simulate wider types.
- Added test coverage for these four operations.
2016-07-07 22:57:38 -04:00
Stephen Canon
5da37a5b1a Round Float.pi down so that it's in [0,π].
* Change value of Float.pi so that it's rounded down; this helps insure that angles computed via trigonometry end up in the correct quadrant.

* Missed commit of corresponding test change.
2016-06-30 16:20:22 -04:00
Dmitri Gribenko
d591f9cf7a stdlib: remove most uses of @warn_unused_result, which does nothing now
I kept the one on sorted(), because that one requires a less trivial
change.
2016-05-19 18:39:39 -07:00
Nate Cook
298f5d9b23 [stdlib] Add missing abstracts to a few types 2016-05-19 13:18:02 -05:00
Dmitri Gribenko
314dfe0ab3 stdlib: remove deprecated floating point APIs 2016-05-17 23:41:51 -07:00
practicalswift
21c872c590 [gardening] Fix recently introduced typos. 2016-05-14 20:33:28 +02:00
Stephen Canon
71e7767346 Make sure @_transparent and @warn_unused_result are on operators where appropriate. 2016-05-11 18:08:23 -04:00
Stephen Canon
6802c5e263 Restore public on top-level operators, mark -- and ++ unavailable for CGFloat. 2016-05-09 18:35:52 -04:00
Stephen Canon
dd1f116cc3 Reinstate Strideable, switch static lets to @inline(__always). 2016-05-09 16:19:40 -04:00
Stephen Canon
6429eabf74 Implement the new FloatingPoint protocols from SE-0067.
There are a couple of features that are not yet implemented, because they require additions to the Builtin module.  Specifically, this implementation does not have:

- formRemainder(dividingBy:)
- formSquareRoot()
- addProduct(_:,_:)

Also missing are the generic initializers and comparisons whose implementation depends on having new Integer protocols.

The last remaining feature of SE-0067 is that while the basic operators +,-,*,/, etc are moved onto the FloatingPoint protocol, they are still required on the concrete types in order to disambiguate overloads.  Fixing this seems to require either modifying the overload resolution rules or removing these operators from some other protocols.  Or it might just require that someone smarter than me looks at the problem.

Passes all the existing tests (with the included changes).  I'm working on additional tests for the new features.
2016-05-09 10:34:13 -04:00
Chris Lattner
8e12008d2b Mark tuple splat and ++/-- as errors instead of warnings. This
wraps up SE-0004 and SE-0029.

I consider the diagnostic changes in Constraints/lvalues.swift to be
indicative of a QoI regression, but I'll deal with that separately.
2016-04-16 23:44:22 -07:00
practicalswift
c760f6dfbf [gardening] Add whitespace: "foo,bar" → "foo, bar" 2016-04-12 22:31:46 +02:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Jordan Rose
6dd1f0a5f9 [stdlib] Apply @_fixed_layout to various stdlib and overlay types
This is a staging attribute that will eventually mean "fixed-contents"
for structs and "closed" for enums, as described in
docs/LibraryEvolution.rst.

This is pretty much the minimal set of types that must be fixed-layout,
because SILGen makes assumptions about their lowering.

If desired, some SILGen refactoring can allow some of these to be
resilient. For example, bridging value types could be made to work
with resilient types.
2016-04-01 13:07:18 -07:00
Saleem Abdulrasool
84e69cc657 stdlib: disable FP80 on Windows
The Windows ABI does not support FP80 (it is FP32, FP64 only).  Ensure that FP80
support is guarded by an OS check.
2016-03-23 08:00:30 -07:00
practicalswift
1b232e9b71 [Python] Remove unused functions in FloatingPoint.swift.gyb
Removed:
* getExponentBitCount(bits)
* getSignalingNanBitPattern(bits)
* llvmIntrinsicSuffix(bits)
2016-03-12 20:45:08 +01:00
Daniel Duan
276370b599 [stdlib] apply SE-0040 to stdlib 2016-03-11 16:01:41 -08:00
Max Moiseev
a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00
Daniel Duan
2bc78b8c09 [stdlib] update for 'inout' adjustment (SE-0031) 2016-02-26 12:02:29 -08:00
Jordan Rose
979e4a8e34 stdlib: Rename {Float,Double.CGFloat}.NaN to 'nan'
This follows the API guidelines and is consistent with the printed form.
'quietNaN' does not change, though.
2016-02-24 17:46:12 -08:00
Max Moiseev
40b1a0b7e0 [stdlib] all sorts of require renamed back to precondition 2016-02-19 18:21:29 -08:00
Dmitri Gribenko
dd75aed67a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-17 14:40:05 -08:00
Dmitri Gribenko
bf34b047d8 stdlib: lowercase cases of FloatingPointClassification enum 2016-02-15 23:48:02 -08:00
Dmitri Gribenko
efaa39ea79 stdlib: add first argument labels and some other changes to conform to API guidelines 2016-02-15 23:47:54 -08:00
Nate Cook
32f81e8238 Add missing abstracts for types and protocols. 2016-02-11 11:47:27 -06:00
Dmitri Gribenko
9bcd5a1056 Collection.length => .count 2016-01-22 18:41:19 -08:00
Max Moiseev
08e1e4a043 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-11 16:51:11 -08:00
Maxim Moiseev
bf969a385f Merge pull request #894 from nonsensery/fix-inc-if-signed-logic
[stdlib] Remove confusing `incIfSigned` control flow
2016-01-08 17:27:13 -08:00
nonsensery
e76dbd5798 Remove confusing incIfSigned control flow
This function was named exactly backwards (it incremented only when
*not* signed). Investigating this naming error revealed that the call
site was also unclear: `incIfSigned` was called from a block where
`signed` was known to be False). So, I inlined the logic in the one
place where it was actually used, and removed the function.
2016-01-08 15:35:15 -08:00
Doug Gregor
1a38e0ad3b Merge branch 'master' into swift-3-api-guidelines 2016-01-06 15:32:55 -08:00
nonsensery
a23e16199f [stdlib] Fix conversion from (signed) int to float in default init
The default initializer for a float types initializes the value to `0`
by calling a “builtin” function to convert an integer with value `0`
into an “FPIEEE” float with value `0`. The integer value is signed, but
the code was calling a function that expected an unsigned integer.
2016-01-05 16:08:02 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Max Moiseev
200be71583 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-23 10:28:04 -08:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00