annotate libinterp/corefcn/pr-flt-fmt.cc @ 30001:428cccc75cc9

move most functions in variables.cc to octave namespace * variables.h, variables.cc: Move most functions to octave namespace. Provide deprecated inline wrapper functions to preserve old names. Change all uses as needed. (SET_INTERNAL_VARIABLE, SET_NONEMPTY_INTERNAL_STRING_VARIABLE, SET_INTERNAL_VARIABLE_WITH_LIMITS, SET_INTERNAL_VARIABLE_CHOICES): Note that these macros are obsolete. * dirfns.cc, ls-oct-text.cc, pr-flt-fmt.cc, pr-output.cc, svd.cc, ov-base.cc, ov-java.cc, ov-struct.cc, ov-usr-fcn.cc, ov.cc: Eliminate use of SET_INTERNAL_VARIABLE macros.
author John W. Eaton <jwe@octave.org>
date Wed, 18 Aug 2021 11:40:25 -0400
parents 32c3a5805893
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 1993-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
24667
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 # include "config.h"
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "defun.h"
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "error.h"
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "pr-flt-fmt.h"
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include "variables.h"
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 // The precision of the numbers printed by the default output
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 // routines.
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 static int Voutput_precision = 5;
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 int
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 output_precision (void)
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 {
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 return Voutput_precision;
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 }
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 void
24784
4d945f2e5914 eliminate output_max_field width; limit output precision (bug #53167)
John W. Eaton <jwe@octave.org>
parents: 24667
diff changeset
46 set_output_prec (int prec)
24667
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 {
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 Voutput_precision = prec;
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 }
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
51 OCTAVE_NAMESPACE_BEGIN
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
52
24667
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 DEFUN (output_precision, args, nargout,
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 doc: /* -*- texinfo -*-
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 @deftypefn {} {@var{val} =} output_precision ()
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 @deftypefnx {} {@var{old_val} =} output_precision (@var{new_val})
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 @deftypefnx {} {} output_precision (@var{new_val}, "local")
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 Query or set the internal variable that specifies the minimum number of
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 significant figures to display for numeric output.
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
24784
4d945f2e5914 eliminate output_max_field width; limit output precision (bug #53167)
John W. Eaton <jwe@octave.org>
parents: 24667
diff changeset
61 Note that regardless of the value set for @code{output_precision}, the
4d945f2e5914 eliminate output_max_field width; limit output precision (bug #53167)
John W. Eaton <jwe@octave.org>
parents: 24667
diff changeset
62 number of digits of precision displayed is limited to 16 for double
4d945f2e5914 eliminate output_max_field width; limit output precision (bug #53167)
John W. Eaton <jwe@octave.org>
parents: 24667
diff changeset
63 precision values and 7 for single precision values.
4d945f2e5914 eliminate output_max_field width; limit output precision (bug #53167)
John W. Eaton <jwe@octave.org>
parents: 24667
diff changeset
64
24667
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 When called from inside a function with the @qcode{"local"} option, the
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 variable is changed locally for the function and any subroutines it calls.
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 The original variable value is restored when exiting the function.
24784
4d945f2e5914 eliminate output_max_field width; limit output precision (bug #53167)
John W. Eaton <jwe@octave.org>
parents: 24667
diff changeset
68
4d945f2e5914 eliminate output_max_field width; limit output precision (bug #53167)
John W. Eaton <jwe@octave.org>
parents: 24667
diff changeset
69 @seealso{format, fixed_point_format}
24667
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 @end deftypefn */)
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 {
30001
428cccc75cc9 move most functions in variables.cc to octave namespace
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
72 return set_internal_variable (Voutput_precision, args, nargout,
428cccc75cc9 move most functions in variables.cc to octave namespace
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
73 "output_precision", 0, 16);
24667
56f889d66b7c move float_format container to setparate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
75
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
76 OCTAVE_NAMESPACE_END