Mercurial > hg > octave-lyh
changeset 5951:b2167e370f82
[project @ 2006-08-22 05:13:42 by jwe]
author | jwe |
---|---|
date | Tue, 22 Aug 2006 05:13:42 +0000 |
parents | 2b2e5a937c59 |
children | 7dc99bfdd87a |
files | src/ChangeLog src/ls-mat-ascii.cc src/ls-oct-ascii.cc |
diffstat | 3 files changed, 27 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2006-08-22 John W. Eaton <jwe@octave.org> + + * ls-oct-ascii.cc: Increase default value of save_precision to 16. + + * ls-mat-ascii.cc (save_mat5_ascii_data): Use scientific format. + 2006-08-21 John W. Eaton <jwe@octave.org> * ls-mat5.cc (read_mat5_binary_data, read_mat5_integer_data,
--- a/src/ls-mat-ascii.cc +++ b/src/ls-mat-ascii.cc @@ -334,9 +334,6 @@ { bool success = true; - long old_precision = os.precision (); - os.precision (precision); - if (val.is_complex_type ()) warning ("save: omitting imaginary part for ASCII file"); @@ -349,9 +346,20 @@ error_state = 0; } else - os << m; + { + long old_precision = os.precision (); + + os.precision (precision); - os.precision (old_precision); + std::ios::fmtflags oflags + = os.flags (static_cast<std::ios::fmtflags> (std::ios::scientific)); + + os << m; + + os.flags (oflags); + + os.precision (old_precision); + } return (os && success); }
--- a/src/ls-oct-ascii.cc +++ b/src/ls-oct-ascii.cc @@ -68,7 +68,7 @@ #include "ls-oct-ascii.h" // The number of decimal digits to use when writing ascii data. -static int Vsave_precision = 15; +static int Vsave_precision = 16; // Functions for reading ascii data. @@ -357,15 +357,9 @@ { bool success = true; - if (! precision) - precision = Vsave_precision; - if (! name.empty ()) os << "# name: " << name << "\n"; - long old_precision = os.precision (); - os.precision (precision); - octave_value val = val_arg; if (mark_as_global) @@ -373,7 +367,13 @@ else os << "# type: " << val.type_name() << "\n"; - success = val . save_ascii(os, infnan_warned, strip_nan_and_inf); + if (! precision) + precision = Vsave_precision; + + long old_precision = os.precision (); + os.precision (precision); + + success = val . save_ascii (os, infnan_warned, strip_nan_and_inf); os.precision (old_precision);