@@ -19,7 +19,7 @@ extension Double {
1919 /// let root = x.c.sqrt // 1.41421356...
2020 /// let sine = x.c.sin // 0.90929742...
2121 /// let log = x.c.log // 0.693147180...
22- /// let abs = (-x).c.fabs // 2.0
22+ /// let abs = (-x).c.abs // 2.0
2323 /// ```
2424 ///
2525 /// ## See Also
@@ -185,7 +185,7 @@ extension Double.C {
185185 ///
186186 /// Delegates to ``ISO_9899/Math/fabs(_:)-1w0zq``
187187 @_transparent
188- public var fabs : Double {
188+ public var abs : Double {
189189 ISO_9899 . Math. fabs ( self . value)
190190 }
191191
@@ -369,35 +369,43 @@ extension Double.C {
369369 ISO_9899 . Math. nearbyint ( self . value)
370370 }
371371
372- /// Round to nearest integer and return as Int
372+ /// Round to nearest integer using current rounding mode
373+ ///
374+ /// Returns the rounded value as an `Int`, using the current FPU rounding direction.
373375 ///
374376 /// Delegates to ``ISO_9899/Math/lrint(_:)-7abaz``
375377 @_transparent
376- public var lrint : Int {
378+ public func roundedToInt ( ) -> Int {
377379 ISO_9899 . Math. lrint ( self . value)
378380 }
379381
380- /// Round to nearest integer and return as Int64
382+ /// Round to nearest integer using current rounding mode
383+ ///
384+ /// Returns the rounded value as an `Int64`, using the current FPU rounding direction.
381385 ///
382386 /// Delegates to ``ISO_9899/Math/llrint(_:)-61a0k``
383387 @_transparent
384- public var llrint : Int64 {
388+ public func roundedToInt64 ( ) -> Int64 {
385389 ISO_9899 . Math. llrint ( self . value)
386390 }
387391
388- /// Round (ties away from zero) and return as Int
392+ /// Round to nearest integer (ties away from zero)
393+ ///
394+ /// Returns the rounded value as an `Int`, with ties rounded away from zero.
389395 ///
390396 /// Delegates to ``ISO_9899/Math/lround(_:)-4gv6i``
391397 @_transparent
392- public var lround : Int {
398+ public func roundToInt ( ) -> Int {
393399 ISO_9899 . Math. lround ( self . value)
394400 }
395401
396- /// Round (ties away from zero) and return as Int64
402+ /// Round to nearest integer (ties away from zero)
403+ ///
404+ /// Returns the rounded value as an `Int64`, with ties rounded away from zero.
397405 ///
398406 /// Delegates to ``ISO_9899/Math/llround(_:)-4j6vs``
399407 @_transparent
400- public var llround : Int64 {
408+ public func roundToInt64 ( ) -> Int64 {
401409 ISO_9899 . Math. llround ( self . value)
402410 }
403411}
@@ -409,7 +417,7 @@ extension Double.C {
409417 ///
410418 /// Delegates to ``ISO_9899/Math/fmod(_:_:)-47htk``
411419 @_transparent
412- public func fmod ( _ y: Double ) -> Double {
420+ public func mod ( _ y: Double ) -> Double {
413421 ISO_9899 . Math. fmod ( self . value, y)
414422 }
415423
@@ -433,28 +441,30 @@ extension Double.C {
433441// MARK: - Manipulation Functions (Section 7.12.11)
434442
435443extension Double . C {
436- /// Copy sign from another value
444+ /// Returns self with the sign of another value
445+ ///
446+ /// Returns a value with the magnitude of self and the sign of `other`.
437447 ///
438448 /// Delegates to ``ISO_9899/Math/copysign(_:_:)-76te9``
439449 @_transparent
440- public func copysign ( _ y : Double ) -> Double {
441- ISO_9899 . Math. copysign ( self . value, y )
450+ public func withSign ( of other : Double ) -> Double {
451+ ISO_9899 . Math. copysign ( self . value, other )
442452 }
443453
444- /// Get next representable value toward y
454+ /// Returns the next representable value in the direction of another value
445455 ///
446456 /// Delegates to ``ISO_9899/Math/nextafter(_:_:)-4hj4j``
447457 @_transparent
448- public func nextafter ( _ y : Double ) -> Double {
449- ISO_9899 . Math. nextafter ( self . value, y )
458+ public func nextRepresentable ( toward other : Double ) -> Double {
459+ ISO_9899 . Math. nextafter ( self . value, other )
450460 }
451461
452- /// Get next representable value toward y (long double )
462+ /// Returns the next representable value in the direction of another value (extended precision )
453463 ///
454464 /// Delegates to ``ISO_9899/Math/nexttoward(_:_:)-71rr4``
455465 @_transparent
456- public func nexttoward ( _ y : Double ) -> Double {
457- ISO_9899 . Math. nexttoward ( self . value, y )
466+ public func nextRepresentableExtended ( toward other : Double ) -> Double {
467+ ISO_9899 . Math. nexttoward ( self . value, other )
458468 }
459469}
460470
@@ -463,102 +473,127 @@ extension Double.C {
463473extension Double . C {
464474 /// Classify floating-point value
465475 ///
476+ /// Returns the classification of the value (normal, zero, subnormal, infinite, or NaN).
477+ ///
466478 /// Delegates to ``ISO_9899/Math/fpclassify(_:)-76te9``
467479 @_transparent
468- public var fpclassify : ISO_9899 . Math . FloatingPointClass {
480+ public var classification : ISO_9899 . Math . FloatingPointClass {
469481 ISO_9899 . Math. fpclassify ( self . value)
470482 }
471483
472484 /// Test for finite value
473485 ///
486+ /// Returns `true` if the value is finite (not infinite or NaN).
487+ ///
474488 /// Delegates to ``ISO_9899/Math/isfinite(_:)-76te9``
475489 @_transparent
476- public var isfinite : Bool {
490+ public var isFinite : Bool {
477491 ISO_9899 . Math. isfinite ( self . value)
478492 }
479493
480494 /// Test for infinity
481495 ///
496+ /// Returns `true` if the value is positive or negative infinity.
497+ ///
482498 /// Delegates to ``ISO_9899/Math/isinf(_:)-76te9``
483499 @_transparent
484- public var isinf : Bool {
500+ public var isInfinite : Bool {
485501 ISO_9899 . Math. isinf ( self . value)
486502 }
487503
488504 /// Test for NaN
489505 ///
506+ /// Returns `true` if the value is Not-a-Number (NaN).
507+ ///
490508 /// Delegates to ``ISO_9899/Math/isnan(_:)-76te9``
491509 @_transparent
492- public var isnan : Bool {
510+ public var isNaN : Bool {
493511 ISO_9899 . Math. isnan ( self . value)
494512 }
495513
496514 /// Test for normal value
497515 ///
516+ /// Returns `true` if the value is normal (not zero, subnormal, infinite, or NaN).
517+ ///
498518 /// Delegates to ``ISO_9899/Math/isnormal(_:)-76te9``
499519 @_transparent
500- public var isnormal : Bool {
520+ public var isNormal : Bool {
501521 ISO_9899 . Math. isnormal ( self . value)
502522 }
503523
504- /// Test sign bit
524+ /// Test if sign bit is set
525+ ///
526+ /// Returns `true` if the sign bit is set (negative), including for -0.0 and -NaN.
505527 ///
506528 /// Delegates to ``ISO_9899/Math/signbit(_:)-76te9``
507529 @_transparent
508- public var signbit : Bool {
530+ public var hasNegativeSign : Bool {
509531 ISO_9899 . Math. signbit ( self . value)
510532 }
511533}
512534
513535// MARK: - Comparison Macros (Section 7.12.14)
514536
515537extension Double . C {
516- /// Determine whether value > y (quiet comparison)
538+ /// Determine whether self > other (quiet comparison)
539+ ///
540+ /// Unlike the `>` operator, this does not raise an exception when comparing with NaN.
517541 ///
518542 /// Delegates to ``ISO_9899/Math/isgreater(_:_:)-76te9``
519543 @_transparent
520- public func isgreater ( _ y : Double ) -> Bool {
521- ISO_9899 . Math. isgreater ( self . value, y )
544+ public func isGreater ( than other : Double ) -> Bool {
545+ ISO_9899 . Math. isgreater ( self . value, other )
522546 }
523547
524- /// Determine whether value >= y (quiet comparison)
548+ /// Determine whether self >= other (quiet comparison)
549+ ///
550+ /// Unlike the `>=` operator, this does not raise an exception when comparing with NaN.
525551 ///
526552 /// Delegates to ``ISO_9899/Math/isgreaterequal(_:_:)-76te9``
527553 @_transparent
528- public func isgreaterequal ( _ y : Double ) -> Bool {
529- ISO_9899 . Math. isgreaterequal ( self . value, y )
554+ public func isGreaterOrEqual ( to other : Double ) -> Bool {
555+ ISO_9899 . Math. isgreaterequal ( self . value, other )
530556 }
531557
532- /// Determine whether value < y (quiet comparison)
558+ /// Determine whether self < other (quiet comparison)
559+ ///
560+ /// Unlike the `<` operator, this does not raise an exception when comparing with NaN.
533561 ///
534562 /// Delegates to ``ISO_9899/Math/isless(_:_:)-76te9``
535563 @_transparent
536- public func isless ( _ y : Double ) -> Bool {
537- ISO_9899 . Math. isless ( self . value, y )
564+ public func isLess ( than other : Double ) -> Bool {
565+ ISO_9899 . Math. isless ( self . value, other )
538566 }
539567
540- /// Determine whether value <= y (quiet comparison)
568+ /// Determine whether self <= other (quiet comparison)
569+ ///
570+ /// Unlike the `<=` operator, this does not raise an exception when comparing with NaN.
541571 ///
542572 /// Delegates to ``ISO_9899/Math/islessequal(_:_:)-76te9``
543573 @_transparent
544- public func islessequal ( _ y : Double ) -> Bool {
545- ISO_9899 . Math. islessequal ( self . value, y )
574+ public func isLessOrEqual ( to other : Double ) -> Bool {
575+ ISO_9899 . Math. islessequal ( self . value, other )
546576 }
547577
548- /// Determine whether value < y or value > y (quiet comparison)
578+ /// Determine whether self != other (quiet comparison)
579+ ///
580+ /// Returns `true` if self < other or self > other (excludes equal and unordered).
581+ /// Unlike `!=`, this does not raise an exception when comparing with NaN.
549582 ///
550583 /// Delegates to ``ISO_9899/Math/islessgreater(_:_:)-76te9``
551584 @_transparent
552- public func islessgreater ( _ y : Double ) -> Bool {
553- ISO_9899 . Math. islessgreater ( self . value, y )
585+ public func isNotEqual ( to other : Double ) -> Bool {
586+ ISO_9899 . Math. islessgreater ( self . value, other )
554587 }
555588
556589 /// Determine whether arguments are unordered
557590 ///
591+ /// Returns `true` if either self or other is NaN.
592+ ///
558593 /// Delegates to ``ISO_9899/Math/isunordered(_:_:)-76te9``
559594 @_transparent
560- public func isunordered ( _ y : Double ) -> Bool {
561- ISO_9899 . Math. isunordered ( self . value, y )
595+ public func isUnordered ( with other : Double ) -> Bool {
596+ ISO_9899 . Math. isunordered ( self . value, other )
562597 }
563598}
564599
@@ -567,25 +602,27 @@ extension Double.C {
567602extension Double . C {
568603 /// Compute positive difference
569604 ///
605+ /// Returns `self - y` if `self > y`, otherwise `+0`.
606+ ///
570607 /// Delegates to ``ISO_9899/Math/fdim(_:_:)-2rksv``
571608 @_transparent
572- public func fdim ( _ y: Double ) -> Double {
609+ public func positiveDifference ( from y: Double ) -> Double {
573610 ISO_9899 . Math. fdim ( self . value, y)
574611 }
575612
576613 /// Determine maximum value
577614 ///
578615 /// Delegates to ``ISO_9899/Math/fmax(_:_:)-8ks7i``
579616 @_transparent
580- public func fmax ( _ y: Double ) -> Double {
617+ public func max ( _ y: Double ) -> Double {
581618 ISO_9899 . Math. fmax ( self . value, y)
582619 }
583620
584621 /// Determine minimum value
585622 ///
586623 /// Delegates to ``ISO_9899/Math/fmin(_:_:)-9yw9t``
587624 @_transparent
588- public func fmin ( _ y: Double ) -> Double {
625+ public func min ( _ y: Double ) -> Double {
589626 ISO_9899 . Math. fmin ( self . value, y)
590627 }
591628
0 commit comments