Mercurial > hg > may
changeset 532:326a52ed74a4
More formatting
author | Chris Cannam |
---|---|
date | Wed, 05 Mar 2014 10:13:38 +0000 |
parents | 77ada441f95a |
children | 6ad790af9c88 |
files | src/may/complex.yeti src/may/matrix.yeti |
diffstat | 2 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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)"
--- 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])