Limit displayed error percentage

When calculating E series resistors, display error percentage down to
0.01% but rather than showing 0.00% error for smaller values, we now
  show the error is "<0.01%" until it is exact.

Fixes https://gitlab.com/kicad/code/kicad/issues/5731
This commit is contained in:
Seth Hillbrand 2020-09-21 06:18:55 -07:00
parent 492a634413
commit 3eb7dc6eef
1 changed files with 30 additions and 16 deletions

View File

@ -334,11 +334,18 @@ void PCB_CALCULATOR_FRAME::OnCalculateESeries( wxCommandEvent& event )
if( error )
{
es.Printf( "%+.2f",error); // if 2R solution with error
if( std::abs( error ) < 0.01 )
{
es.Printf( "<0.01" );
}
else
{
es.Printf( "%+.2f",error);
}
}
else
{
es = "Exact"; // 2R solution is already exact
es = "Exact";
}
m_ESeriesError2R->SetValue( es ); // anyway show 2R error string
@ -348,9 +355,16 @@ void PCB_CALCULATOR_FRAME::OnCalculateESeries( wxCommandEvent& event )
err3 = reqr + r.get_rslt()[S3R].e_value; // calculate the 3R
err3 = ( reqr / err3 - 1 ) * 100; // error in percent
if( err3 ) // build 3R error string
if( err3 )
{
es.Printf( "%+.2f",err3);
if( std::abs( err3 ) < 0.01 )
{
es.Printf( "<0.01" );
}
else
{
es.Printf( "%+.2f",err3);
}
}
else
{