Skip to content

Commit 79304e2

Browse files
committed
Cleanup: integer bounds n' precision.
1 parent 1aa1cb5 commit 79304e2

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

Sources/DiffableTextKitXNumber/Graphs/Graph+Integers.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,9 @@ where Value: _Input & FixedWidthInteger {
3939
/// - Limited by longest sequence of 9s due to IntegerFormatStyle.
4040
fileprivate init() where Value: LosslessStringConvertible {
4141
let limit = Value(clamping: Int.max)
42-
//=--------------------------------------=
43-
// Precision
44-
//=--------------------------------------=
4542
self.precision = Int(floor(log10(Double(limit))))
46-
let nines = String(repeating: "9", count: precision)
47-
//=--------------------------------------=
48-
// Bounds
49-
//=--------------------------------------=
50-
self.max = Value(nines)! // max <= precision, 9s <= Int.max
51-
self.min = Value.isSigned ? Value("-" + nines)! : Value.min
43+
self.max = Value(String(repeating: "9", count: precision))!
44+
self.min = Value(clamping: -1) * max // zero when unsigned
5245
}
5346

5447
//=------------------------------------------------------------------------=

0 commit comments

Comments
 (0)