EgtGeneral 2.7i1 :
- aggiunta ToStringAdv per long long.
This commit is contained in:
Binary file not shown.
@@ -152,6 +152,32 @@ ToStringAdv( unsigned int nVal, int nPrec, int nRadix, int* pnErr)
|
||||
return sBuff ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string
|
||||
ToStringAdv( long long nVal, int nPrec, int nRadix, int* pnErr)
|
||||
{
|
||||
// eseguo conversione
|
||||
const int nBuffSize = 68 ;
|
||||
char szBuff[nBuffSize]{} ;
|
||||
auto Res = std::to_chars( szBuff, szBuff + nBuffSize - 1, nVal, nRadix) ;
|
||||
if ( Res.ec != std::errc()) {
|
||||
if ( pnErr != nullptr)
|
||||
*pnErr = int( Res.ec) ;
|
||||
return "#Error" ;
|
||||
}
|
||||
// gestione codice di errore
|
||||
if ( pnErr != nullptr)
|
||||
*pnErr = 0 ;
|
||||
// verifico lunghezza minima
|
||||
int nLen = (int) strlen( szBuff) ;
|
||||
if ( nLen >= nPrec)
|
||||
return szBuff ;
|
||||
// porto la stringa alla minima lunghezza
|
||||
std::string sBuff( szBuff) ;
|
||||
sBuff.insert( 0, ( nPrec - nLen), '0') ;
|
||||
return sBuff ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string
|
||||
ToString( double dVal, int nPrec, int* pnErr)
|
||||
|
||||
Reference in New Issue
Block a user