2727#include < fmt/printf.h>
2828#include < fmt/format.h>
2929#include < fmt/xchar.h>
30- #include < type_traits>
3130#include " FormatEngineeringNotation.hpp"
3231#include " IEEEFP.hpp"
3332// =============================================================================
@@ -114,7 +113,7 @@ formatLongEng(single number, bool trim)
114113// =============================================================================
115114template <class T >
116115std::wstring
117- formatComplexLongEng (T realPart, T imagPart, bool trim)
116+ formatComplexLongEng (T realPart, T imagPart, bool trim, size_t nbMaxBlanks )
118117{
119118 std::wstring result;
120119 result.append (formatLongEng (realPart, trim));
@@ -123,32 +122,29 @@ formatComplexLongEng(T realPart, T imagPart, bool trim)
123122 } else {
124123 result.append (L" +" );
125124 }
125+ std::wstring imgStr = formatLongEng ((T)fabs (imagPart), false );
126126 if (std::isfinite (imagPart)) {
127- std::wstring imgStr = formatLongEng (fabs (imagPart), false );
128- size_t nbMaxBlanks = std::is_same<T, float >::value ? 2 : 3 ;
129127 for (size_t k = 0 ; k < nbMaxBlanks; ++k) {
130128 if (imgStr[0 ] == L' ' ) {
131129 imgStr.erase (0 , 1 );
132130 }
133131 }
134- result.append (imgStr);
135- } else {
136- result.append (formatLongEng (fabs (imagPart), false ));
137132 }
133+ result.append (imgStr);
138134 result.append (L" i" );
139135 return result;
140136}
141137// =============================================================================
142138std::wstring
143139formatComplexLongEng (double realPart, double imagPart, bool trim)
144140{
145- return formatComplexLongEng<double >(realPart, imagPart, trim);
141+ return formatComplexLongEng<double >(( double ) realPart, ( double ) imagPart, trim, 3 );
146142}
147143// =============================================================================
148144std::wstring
149145formatComplexLongEng (single realPart, single imagPart, bool trim)
150146{
151- return formatComplexLongEng<single>(realPart, imagPart, trim);
147+ return formatComplexLongEng<single>((single) realPart, (single) imagPart, trim, 2 );
152148}
153149// =============================================================================
154150template <class T >
0 commit comments