Ensure values with units are displayed correctly when numbers are very small.

from master branch.
see 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 bab61dd249
commit 74adbbcc5d
1 changed files with 6 additions and 0 deletions

View File

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