Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
//
// StdLib+NYPLAdditions.swift
// Simplified
//
// Created by Ettore Pasquini on 6/17/20.
// Copyright © 2020 NYPL. All rights reserved.
// Copyright © 2024 The New York Public Library. All Rights Reserved.
//

import Foundation

infix operator =~= : ComparisonPrecedence

public extension Float {
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: Float, b: Float?) -> Bool {
static func =~= (a: Double, b: Double?) -> Bool {
guard let b = b else {
return false
}

return abs(a - b) < Float.ulpOfOne
return abs(a - b) < Double.ulpOfOne
}

func roundTo(decimalPlaces: Int) -> String {
Expand Down