Fix simulator: op results are not printed correctly when numbers are very small

Was due to an overflow in units calculation.

Fixes #5074
https://gitlab.com/kicad/code/kicad/issues/5074
This commit is contained in:
jean-pierre charras 2020-08-08 15:18:50 +02:00
parent 61ada3a602
commit 111ed6c4ac
1 changed files with 6 additions and 0 deletions

View File

@ -90,12 +90,18 @@ void SPICE_VALUE::Normalize()
{
m_base *= 0.001;
m_prefix = (UNIT_PREFIX)( m_prefix + 3 );
if( m_prefix == PFX_TERA ) // this is the biggest unit available
break;
}
while( m_base != 0.0 && std::fabs( m_base ) < 1.000 )
{
m_base *= 1000.0;
m_prefix = (UNIT_PREFIX)( m_prefix - 3 );
if( m_prefix == PFX_FEMTO ) // this is the smallest unit available
break;
}
}