# HG changeset patch # User Chris Cannam # Date 1394014418 0 # Node ID 326a52ed74a45399b76b6fdbf0a0155429cc26f2 # Parent 77ada441f95a2c35bb57950ea11620f3db8733ee More formatting diff -r 77ada441f95a -r 326a52ed74a4 src/may/complex.yeti --- a/src/may/complex.yeti Tue Mar 04 16:46:56 2014 +0000 +++ b/src/may/complex.yeti Wed Mar 05 10:13:38 2014 +0000 @@ -31,13 +31,16 @@ fi, String format() (f v r = - //!!! not right -- want to round to 1dp of exp notation if less than 1e-4 - (n = mm.round (v * 10000); - s = "\(n / 10000)"; + (s = if v == 0.0 then "0.0" + elif abs v >= 1000.0 or abs v < 0.01 then + String#format("%.1E", [v as ~Double]) + else + String#format("%4f", [v as ~Double]) + fi; if r then - (strPad ' ' (8 - strLength s) '') ^ s + (strPad ' ' (9 - strLength s) '') ^ s else - strPad ' ' 7 "\(s)i"; + strPad ' ' 8 "\(s)i"; fi); if imag < 0 then " \(f real true)-\(f (-imag) false)" diff -r 77ada441f95a -r 326a52ed74a4 src/may/matrix.yeti --- a/src/may/matrix.yeti Tue Mar 04 16:46:56 2014 +0000 +++ b/src/may/matrix.yeti Wed Mar 05 10:13:38 2014 +0000 @@ -881,7 +881,8 @@ (map do row: map do v: strPad ' ' 10 - (if abs v >= 1000.0 or abs v < 0.01 then + (if v == 0 then "0.0" + elif abs v >= 1000.0 or abs v < 0.01 then String#format("%.2E", [v as ~Double]) else String#format("%5f", [v as ~Double])