This file contains hidden or 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
extension Binding where Value == Double { | |
/// Returns a new version of the binding that scales the value logarithmically using the specified base. That is, | |
/// when getting the value, `log_b(value)` is returned; when setting it, the new value is `pow(base, newValue)`. | |
/// | |
/// - Parameter base: The base to use. | |
func logarithmic(base: Double = 10) -> Binding<Double> { | |
Binding( | |
get: { | |
log10(self.wrappedValue) / log10(base) | |
}, |
This file contains hidden or 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
import Foundation | |
import SwiftUI | |
struct FormattedTextFieldView : View { | |
@State private var double = 0.5 | |
@State private var nsNumber: NSNumber = 0.5 | |
static let numberFormatter: NumberFormatter = { |
This file contains hidden or 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
import Foundation | |
struct ByteFormatStyle<Bytes> : FormatStyle, Hashable, Sendable where Bytes : Collection, Bytes.Element == UInt8 { | |
typealias FormatInput = Bytes | |
typealias FormatOutput = String | |
var radix: Int = 16 | |
var uppercase: Bool = false |
OlderNewer