GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pr-flt-fmt.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include "defun.h"
31 #include "error.h"
32 #include "pr-flt-fmt.h"
33 #include "variables.h"
34 
35 // The precision of the numbers printed by the default output
36 // routines.
37 static int Voutput_precision = 5;
38 
39 int
41 {
42  return Voutput_precision;
43 }
44 
45 void
46 set_output_prec (int prec)
47 {
48  Voutput_precision = prec;
49 }
50 
51 DEFUN (output_precision, args, nargout,
52  doc: /* -*- texinfo -*-
53 @deftypefn {} {@var{val} =} output_precision ()
54 @deftypefnx {} {@var{old_val} =} output_precision (@var{new_val})
55 @deftypefnx {} {} output_precision (@var{new_val}, "local")
56 Query or set the internal variable that specifies the minimum number of
57 significant figures to display for numeric output.
58 
59 Note that regardless of the value set for @code{output_precision}, the
60 number of digits of precision displayed is limited to 16 for double
61 precision values and 7 for single precision values.
62 
63 When called from inside a function with the @qcode{"local"} option, the
64 variable is changed locally for the function and any subroutines it calls.
65 The original variable value is restored when exiting the function.
66 
67 @seealso{format, fixed_point_format}
68 @end deftypefn */)
69 {
71 }
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
static int Voutput_precision
Definition: pr-flt-fmt.cc:37
int output_precision(void)
Definition: pr-flt-fmt.cc:40
void set_output_prec(int prec)
Definition: pr-flt-fmt.cc:46
#define SET_INTERNAL_VARIABLE_WITH_LIMITS(NM, MINVAL, MAXVAL)
Definition: variables.h:109