diff --git a/Sources/Number/Double+NYPLAdditions.swift b/Sources/Number/Double+NYPLAdditions.swift new file mode 100644 index 0000000..6ec0fce --- /dev/null +++ b/Sources/Number/Double+NYPLAdditions.swift @@ -0,0 +1,22 @@ +// +// Created by Ettore Pasquini on 11/29/24. +// Copyright © 2024 The New York Public Library. All Rights Reserved. +// + +import Foundation + +infix operator =~= : ComparisonPrecedence + +public extension Double { + + /// Performs equality check minus an epsilon + /// - Returns: `true` if the numbers differ by less than the epsilon, + /// `false` otherwise. + static func =~= (a: Double, b: Double?) -> Bool { + guard let b = b else { + return false + } + + return abs(a - b) < Double.ulpOfOne + } +} diff --git a/Sources/Number/Float+NYPLAdditions.swift b/Sources/Number/Float+NYPLAdditions.swift deleted file mode 100644 index 817e4f3..0000000 --- a/Sources/Number/Float+NYPLAdditions.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// StdLib+NYPLAdditions.swift -// Simplified -// -// Created by Ettore Pasquini on 6/17/20. -// Copyright © 2020 NYPL. All rights reserved. -// - -import Foundation - -infix operator =~= : ComparisonPrecedence - -public extension Float { - - /// Performs equality check minus an epsilon - /// - Returns: `true` if the numbers differ by less than the epsilon, - /// `false` otherwise. - static func =~= (a: Float, b: Float?) -> Bool { - guard let b = b else { - return false - } - - return abs(a - b) < Float.ulpOfOne - } - - func roundTo(decimalPlaces: Int) -> String { - return String(format: "%.\(decimalPlaces)f%%", self) as String - } -} -