I am working a new tac. I use my existing Double extension I call EE() on each of the elements of a simd_double3, which obviously has three double elements.
I've abandoned SIMD3 with its scalars.
so:
extension simd_double3 {
func EE_simd_double3(_ sigDig: Int?,_ toSize: Int?,_ padChar: String?) -> String {
return "(\((self.x).EE(sigDig,toSize,padChar)), \((self.y).EE(sigDig,toSize,padChar)), \((self.z).EE(sigDig,toSize,padChar)))"
}
}
extension Double {
func EE(_ sigDig: Int?,_ toSize: Int?,_ padChar: String?) -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .scientific
formatter.positivePrefix = "+"
formatter.maximumIntegerDigits = 1
formatter.usesSignificantDigits = true
formatter.minimumSignificantDigits = sigDig ?? 4
formatter.maximumSignificantDigits = sigDig ?? 5
return formatter.string(from: self as NSNumber)!.pad(padWithString: padChar ?? " ", toSize: toSize ?? 16, prefix: false) //.padding(toLength: padTo ?? 26, withPad: padChar ?? " ", startingAt: stringNum.count)
}
}
My remaining problems are how to include the plus sign after the E in scientific nation, e.g.,
-4.516611095E1 -> -4.516611095E+1
and to specify the number of digits after E, e.g.,
-4.516611095E1 -> -4.516611095E+01