@@ -55,23 +55,25 @@ constexpr dsga::vec3 right_handed_normal(const dsga::vec3 &v1, const dsga::vec3
5555
5656// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5757
58- // iostream output operator for STL ASCII output -- need to set scientific and precision==9 on the stream
58+ // iostream output operator for STL ASCII output -- need to set scientific and precision==9 on the stream (actually 8, because
59+ // std::scientific format only counts digits *after* the decimal point.
60+ // see https://www.zverovich.net/2023/06/04/printing-double.html
5961template <dsga::dimensional_scalar T, std::size_t Size>
6062inline std::ostream &operator <<(std::ostream &o, const dsga::basic_vector<T, Size> &v)
6163{
6264 o << v[0 ];
6365 for (int i = 1 ; i < v.length (); ++i)
64- o << " " << v[i];
66+ o << " " << std::scientific << v[i];
6567 return o;
6668}
6769
6870// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6971
7072bool maybe_binary_stl (std::ifstream &some_file, uintmax_t size)
7173{
72- constexpr auto facet_size = 50u ;
73- constexpr auto header_size = 80u ;
74- constexpr auto num_facets_size = 4u ;
74+ constexpr uintmax_t facet_size = 50u ;
75+ constexpr uintmax_t header_size = 80u ;
76+ constexpr uintmax_t num_facets_size = 4u ;
7577 bool maybe_val = false ;
7678 unsigned int num_facets{};
7779
@@ -190,8 +192,7 @@ bool convert_binary_stl_to_ascii(std::ifstream &some_file, std::ofstream &out_fi
190192 some_file.seekg (header_size + num_facets_size);
191193
192194 // iostream ASCII STL float format
193- out_file.setf (std::ios::scientific);
194- out_file.precision (9 );
195+ out_file.precision (std::numeric_limits<float >::max_digits10 - 1 );
195196
196197 // convert input to output
197198 out_file << solid_open;
0 commit comments