Last active
August 17, 2022 09:40
-
-
Save anisoptera/5708afc32454ed868363 to your computer and use it in GitHub Desktop.
The overloads I've been dying to write since I started working with NSDecimalNumbers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The overloads I've been dying to write since I started working with NSDecimalNumbers. | |
import Foundation | |
@infix func > (left:NSDecimalNumber, right:NSDecimalNumber) -> Bool | |
{ | |
return left.compare(right) == NSComparisonResult.OrderedDescending | |
} | |
@infix func < (left:NSDecimalNumber, right:NSDecimalNumber) -> Bool | |
{ | |
return left.compare(right) == NSComparisonResult.OrderedAscending | |
} | |
@infix func >= (left:NSDecimalNumber, right:NSDecimalNumber) -> Bool | |
{ | |
return left.compare(right) != NSComparisonResult.OrderedAscending | |
} | |
@infix func <= (left:NSDecimalNumber, right:NSDecimalNumber) -> Bool | |
{ | |
return left.compare(right) != NSComparisonResult.OrderedDescending | |
} | |
@infix func + (left:NSDecimalNumber, right:NSDecimalNumber) -> NSDecimalNumber | |
{ | |
return left.decimalNumberByAdding(right) | |
} | |
@infix func * (left:NSDecimalNumber, right:NSDecimalNumber) -> NSDecimalNumber | |
{ | |
return left.decimalNumberByMultiplyingBy(right) | |
} | |
@infix func - (left:NSDecimalNumber, right:NSDecimalNumber) -> NSDecimalNumber | |
{ | |
return left.decimalNumberBySubtracting(right) | |
} | |
@infix func / (left:NSDecimalNumber, right:NSDecimalNumber) -> NSDecimalNumber | |
{ | |
return left.decimalNumberByDividingBy(right) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment