swhitty / SwiftDraw
Showing 1 of 1 files from the diff.

@@ -63,8 +63,8 @@
Loading
63 63
        return String(describing: c)
64 64
      }
65 65
    }
66 -
    
67 -
    func format(fraction n: Double, maxDigits: Int) -> String {
66 +
67 +
    func format(fraction n: Double, maxDigits: Int) -> String? {
68 68
      assert(n.sign == .plus)
69 69
      
70 70
      let min = pow(Double(10), Double(-maxDigits)) - Double.ulpOfOne
@@ -74,6 +74,9 @@
Loading
74 74
      }
75 75
      
76 76
      let s = String(format: "%.\(maxDigits)g", n)
77 +
      if s == "1" {
78 +
        return nil
79 +
      }
77 80
      let idx = s.index(s.startIndex, offsetBy: 1)
78 81
      return String(s[idx..<s.endIndex])
79 82
    }
@@ -92,8 +95,12 @@
Loading
92 95
      
93 96
      let integer = Int(n.0)
94 97
      let fraction = format(fraction: n.1, maxDigits: capped)
95 -
      
96 -
      return "\(sign)\(integer)\(fraction)"
98 +
99 +
      if let fraction = fraction {
100 +
        return "\(sign)\(integer)\(fraction)"
101 +
      } else {
102 +
        return "\(sign)\(integer + 1)"
103 +
      }
97 104
    }
98 105
  }
99 106
}
Files Coverage
SwiftDraw 76.84%
Project Totals (62 files) 76.84%
1
ignore:
2
  - "SwiftDrawTests"
3
  - "CommandLine"
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading