Meshtastic-Apple/Meshtastic/Extensions/Int.swift

30 lines
434 B
Swift
Raw Normal View History

2023-04-25 17:56:57 -07:00
//
// Int.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 4/25/23.
//
extension Int {
func numberOfDigits() -> Int {
if abs(self) < 10 {
return 1
} else {
return 1 + (self/10).numberOfDigits()
}
}
}
2024-06-23 08:06:59 -07:00
extension UInt32 {
func toHex() -> String {
return String(format: "!%08X", self).lowercased()
2024-06-23 08:06:59 -07:00
}
}
extension Int64 {
func toHex() -> String {
return String(format: "!%08X", self).lowercased()
2024-06-23 08:06:59 -07:00
}
}