Skip to content

Commit

Permalink
Double and CGFloat: Added integralDigitPlaces and `fractionDigi…
Browse files Browse the repository at this point in the history
…tPlaces` properties
  • Loading branch information
orchetect committed Nov 21, 2023
1 parent 7e44c39 commit ee9b7a0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Sources/OTCore/Extensions/CoreGraphics/CGFloat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,27 @@ extension StringProtocol {
}
}

#if canImport(Foundation)
import Foundation

// MARK: - Digit Places

extension CGFloat {
/// **OTCore:**
/// Returns the number of digit places of the ``integral`` portion (left of the decimal).
@inlinable @_disfavoredOverload
public var integralDigitPlaces: Int {
Decimal(self).integralDigitPlaces
}

/// **OTCore:**
/// Returns the number of digit places of the ``fraction`` portion (right of the decimal).
@inlinable @_disfavoredOverload
public var fractionDigitPlaces: Int {
Decimal(self).fractionDigitPlaces
}
}

#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,22 @@ extension FloatingPoint where Self: CVarArg,
}
}

// MARK: - Digit Places

extension Double {
/// **OTCore:**
/// Returns the number of digit places of the ``integral`` portion (left of the decimal).
@inlinable @_disfavoredOverload
public var integralDigitPlaces: Int {
Decimal(self).integralDigitPlaces
}

/// **OTCore:**
/// Returns the number of digit places of the ``fraction`` portion (right of the decimal).
@inlinable @_disfavoredOverload
public var fractionDigitPlaces: Int {
Decimal(self).fractionDigitPlaces
}
}

#endif

0 comments on commit ee9b7a0

Please sign in to comment.