From b80fdad5114177eb092d9e6a5b882b7279b3ff40 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Wed, 17 Feb 2021 18:52:56 -0500 Subject: [PATCH] Don't generate a format specifier length of ":" It's ambiguous, are we talking the length of a human colon or a pigs? Fix #7556 --- eeschema/sim/sim_plot_panel.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/eeschema/sim/sim_plot_panel.cpp b/eeschema/sim/sim_plot_panel.cpp index 7cf51f53f3..eb03461265 100644 --- a/eeschema/sim/sim_plot_panel.cpp +++ b/eeschema/sim/sim_plot_panel.cpp @@ -37,8 +37,7 @@ static wxString formatFloat( double x, int nDigits ) if( nDigits ) { - fmt = wxT( "%.0Nf" ); - fmt[3] = '0' + nDigits; + fmt.Printf( "%%.0%df", nDigits ); } else { @@ -102,6 +101,12 @@ static void getSISuffix( double x, const wxString& unit, int& power, wxString& s static int countDecimalDigits( double x, int maxDigits ) { + if( std::isnan( x ) ) + { + // avoid trying to count the decimals of NaN + return 0; + } + int64_t k = (int)( ( x - floor( x ) ) * pow( 10.0, (double) maxDigits ) ); int n = 0;