 
 import Foundation
 
+protocol OrderOfMagnitude: CaseIterable {
+    //An array of the powers of the magnitudes
+    static func powers() -> [Int]
+
+    //Textual symbols of the magnitudes
+    var symbol:String {get}
+}
+
 ///Enum of ISO prefixes for decimal (base 10) orders of magnitude
-enum DecimalMagnitude: Double {
+enum DecimalMagnitude: Double, OrderOfMagnitude {
     case yocto = 1.0e-24
     case zepto = 1.0e-21
     case atto  = 1.0e-18

        let mag = magnitude(units)
        return (mag.toMagnitude(units), mag)
    }

    internal static func allMagnitudes() -> [Int] {
        allCases.map {Int(log10($0.rawValue))}
    }

    var symbol:String {
        let symbols = ["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi"]
        return symbols[BinaryMagnitude.allCases.firstIndex(of: self)!]
    }
}


        //get index of case <= magnitude...
        // clamp to upper/lower bounds for values outside range
        var index: Int? = powers().lastIndex(where: {$0 <= mag})
        if index == nil {
            index = units.magnitude < 1.0 ? 0 : (allCases.count - 1)
        }
