[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Format in Octave 2.1.30 (more)
From: |
John W. Eaton |
Subject: |
Re: Format in Octave 2.1.30 (more) |
Date: |
Mon, 26 Jun 2000 18:18:42 -0500 (CDT) |
On 13-Jun-2000, Dirk Laurie <address@hidden> wrote:
| Dirk Laurie skryf:
| > Dirk Laurie skryf:
| > > In Octave 2.0.16, a certain matrix prints out as follows:
| > >
| > > 3069300 399292 898170 498922 1666628 1094686 3533559
| ...
| > > In Octave 2.1.30, the same matrix prints out as follows:
| > >
| > > 3.069e+06 3.993e+05 8.982e+05 4.989e+05 1.667e+06 1.095e+06
3.534e+06
| ...
| > I have stumbled on a fix. "format long e" followed by "format" does
| > what I want. Successive calls to "format ..." seem to be dependent on the
| > old state.
| >
| But the fix only works if I actually print out the matrix in between.
Please try the following patch.
Thanks,
jwe
2000-06-26 John W. Eaton <address@hidden>
* pr-output.cc (float_format::float_format): Set default values
for width and precision to -1.
(operator << (ostream&, pr_formatted_float&): Set width and
precision if values are >= 0.
(set_real_format, set_real_matrix_format, set_range_format,
set_complex_format, set_complex_matrix_format): If we have all
integers, infinities, or nans, set precision equal to field width.
Index: pr-output.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/pr-output.cc,v
retrieving revision 1.90
diff -c -r1.90 pr-output.cc
*** pr-output.cc 2000/03/17 09:44:30 1.90
--- pr-output.cc 2000/06/26 22:39:13
***************
*** 104,110 ****
{
public:
! float_format (int w = 0, int p = 0, int f = 0)
: fw (w), prec (p), fmt (f), up (0), sp (0) { }
float_format (const float_format& ff)
--- 104,110 ----
{
public:
! float_format (int w = -1, int p = -1, int f = 0)
: fw (w), prec (p), fmt (f), up (0), sp (0) { }
float_format (const float_format& ff)
***************
*** 177,186 ****
std::ostream&
operator << (std::ostream& os, const pr_formatted_float& pff)
{
! if (pff.f.fw > 0)
os << std::setw (pff.f.fw);
! if (pff.f.prec > 0)
os << std::setprecision (pff.f.prec);
std::ios::fmtflags oflags = os.flags (pff.f.fmt | pff.f.up | pff.f.sp);
--- 177,186 ----
std::ostream&
operator << (std::ostream& os, const pr_formatted_float& pff)
{
! if (pff.f.fw >= 0)
os << std::setw (pff.f.fw);
! if (pff.f.prec >= 0)
os << std::setprecision (pff.f.prec);
std::ios::fmtflags oflags = os.flags (pff.f.fmt | pff.f.up | pff.f.sp);
***************
*** 280,286 ****
if (inf_or_nan && fw < 3)
fw = 3;
fw += sign;
! rd = 0;
}
else
{
--- 280,286 ----
if (inf_or_nan && fw < 3)
fw = 3;
fw += sign;
! rd = fw;
}
else
{
***************
*** 402,408 ****
if (inf_or_nan && fw < 3)
fw = 3;
fw += sign;
! rd = 0;
}
else
{
--- 402,408 ----
if (inf_or_nan && fw < 3)
fw = 3;
fw += sign;
! rd = fw;
}
else
{
***************
*** 548,554 ****
if (inf_or_nan && i_fw < 3)
i_fw = r_fw = 3;
r_fw += sign;
! rd = 0;
}
else
{
--- 548,554 ----
if (inf_or_nan && i_fw < 3)
i_fw = r_fw = 3;
r_fw += sign;
! rd = r_fw;
}
else
{
***************
*** 725,731 ****
if (inf_or_nan && i_fw < 3)
i_fw = r_fw = 3;
r_fw += sign;
! rd = 0;
}
else
{
--- 725,731 ----
if (inf_or_nan && i_fw < 3)
i_fw = r_fw = 3;
r_fw += sign;
! rd = r_fw;
}
else
{
***************
*** 888,894 ****
{
int digits = x_max > x_min ? x_max : x_min;
fw = sign + digits;
! rd = 0;
}
else if (Vfixed_point_format)
{
--- 888,894 ----
{
int digits = x_max > x_min ? x_max : x_min;
fw = sign + digits;
! rd = fw;
}
else if (Vfixed_point_format)
{
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------