GNU Octave 11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
mach-info.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2026 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 "f77-fcn.h"
31#include "mach-info.h"
32#include "oct-error.h"
33
34extern "C"
35{
36 int octave_get_float_format (void);
37
38 int octave_is_big_endian (void);
39}
40
43
44static float_format get_float_format ()
45{
46 switch (octave_get_float_format ())
47 {
48 case 1:
50
51 case 2:
53
54 default:
55 return flt_fmt_unknown;
56 }
57}
58
59static bool
60is_big_endian ()
61{
62 return octave_is_big_endian ();
63}
64
67{
68 static float_format fmt = get_float_format ();
69
70 return fmt;
71}
72
73bool
75{
76 static bool big_endian = is_big_endian ();
77
78 return big_endian;
79}
80
81bool
83{
84 static bool little_endian = ! is_big_endian ();
85
86 return little_endian;
87}
88
89bool
91{
92#if defined (HAVE_QNAN_WITH_PAYLOAD)
93 return 1;
94#else
95 return 0;
96#endif
97}
98
100string_to_float_format (const std::string& s)
101{
103
104 if (s == "native" || s == "n")
105 retval = native_float_format ();
106 else if (s == "ieee-be" || s == "b")
108 else if (s == "ieee-le" || s == "l")
110 else if (s == "unknown")
111 retval = flt_fmt_unknown;
112 else
114 ("invalid architecture type specified");
115
116 return retval;
117}
118
119std::string
121{
122 std::string retval = "unknown";
123
124 switch (flt_fmt)
125 {
127 retval = "ieee-be";
128 break;
129
131 retval = "ieee-le";
132 break;
133
134 default:
135 break;
136 }
137
138 return retval;
139}
140
141OCTAVE_END_NAMESPACE(mach_info)
142OCTAVE_END_NAMESPACE(octave)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
Definition lo-error.c:41
int octave_is_big_endian(void)
Definition cmach-info.c:132
bool words_little_endian()
Definition mach-info.cc:82
std::string float_format_as_string(float_format flt_fmt)
Definition mach-info.cc:120
bool words_big_endian()
Definition mach-info.cc:74
float_format native_float_format()
Definition mach-info.cc:66
bool nan_with_payload()
Definition mach-info.cc:90
float_format string_to_float_format(const std::string &s)
Definition mach-info.cc:100
int octave_get_float_format(void)
Definition cmach-info.c:77
@ flt_fmt_ieee_big_endian
Definition mach-info.h:43
@ flt_fmt_unknown
Definition mach-info.h:41
@ flt_fmt_ieee_little_endian
Definition mach-info.h:42