 }
 
 
-// Compare two double values for "enough" equality.
-func equalEnough(_ a: Double, _ b: Double) -> Bool {
+// Compare two float values for "enough" equality.
+func equalEnough(_ a: Float, _ b: Float) -> Bool {
     let absA = abs(a)
     let absB = abs(b)
 
-    return abs(absA - absB) <= max(absA, absB) * Double.ulpOfOne
-}
-
-func gradientGetIndexOfColorAtPosition(_ gradient: Gradient, _ pos: Double) -> Int? {
+    return abs(absA - absB) <= max(absA, absB) * Float.ulpOfOne
+}
+
+func gradientGetIndexOfColorAtPosition(_ gradient: Gradient, _ pos: Float) -> Int? {
     for i in 0..<gradient.colors.count {
         if equalEnough(gradient.colors[i].pos, pos) {
             return i


            if matches.count == 1 {
                if matches[0].numberOfRanges == 4+1 {
                    let pos = Double((line as NSString).substring(with: matches[0].range(at: 1)))
                    let r = Double((line as NSString).substring(with: matches[0].range(at: 2)))
                    let g = Double((line as NSString).substring(with: matches[0].range(at: 3)))
                    let b = Double((line as NSString).substring(with: matches[0].range(at: 4)))

                    if pos != nil && r != nil && g != nil && b != nil {
                        if let index = gradientGetIndexOfColorAtPosition(gradient, pos!) {

    }
}

func mandelbrotColorize(_ imageWidth: Int, _ imageHeight: Int, _ maxIterations: Int, _ gradient: Gradient, _ imageData: inout [UInt8], _ histogram: [Int], _ iterationsPerPixel: [Int], _ smoothedDistancesToNextIterationPerPixel: [Float], _ normalizedColors: inout [Float]) {
    // Sum all iterations, not counting the last one at position histogram[max_iterations] (which
    // are points in the Mandelbrot Set).
    var totalIterations = 0
