Embedded/common/src/b_BasicEm/String.c
/* converts number to string without 0 termination - returns number of characters written */
converts number to string without 0 termination - returns number of characters written
converts number to string without 0 termination - returns number of characters written
uint32 bbs_cString( int32 valA, char* dstA, uint32 bufSizeA )
{
	uint32 valL = ( valA < 0 ) ? -valA : valA;
	uint32 iL = 0;
	uint32 digitsL = 0;
	if( valA < 0 )
	{
		if( iL < bufSizeA ) dstA[ iL++ ] = '-';
	}
	if( valL == 0 )
	{
		iL++;
	}
	else
	{
		while( valL > 0 )
		{
			iL++;
			valL /= 10;
		}
	}
	digitsL = ( iL > bufSizeA ) ? bufSizeA : iL;
	valL = ( valA < 0 ) ? -valA : valA;
	if( valL == 0 )
	{
		if( iL < bufSizeA ) dstA[ --iL ] = '0';
	}
	else
	{
		while( valL > 0 )
		{
			if( iL < bufSizeA ) dstA[ --iL ] = '0' + ( valL % 10 );
			valL /= 10;
		}
	}
	return digitsL;
}
uint32 bbs_cString ( int32 valA , char * dstA , uint32 bufSizeA ) { uint32 valL = ( valA < 0 ) ? - valA : valA ; uint32 iL = 0 ; uint32 digitsL = 0 ; if ( valA < 0 ) { if ( iL < bufSizeA ) dstA [ iL ++ ] = ' ' ; } if ( valL == 0 ) { iL ++ ; } else { while ( valL > 0 ) { iL ++ ; valL /= 10 ; } } digitsL = ( iL > bufSizeA ) ? bufSizeA : iL ; valL = ( valA < 0 ) ? - valA : valA ; if ( valL == 0 ) { if ( iL < bufSizeA ) dstA [ -- iL ] = ' ' ; } else { while ( valL > 0 ) { if ( iL < bufSizeA ) dstA [ -- iL ] = ' ' + ( valL % 10 ) ; valL /= 10 ; } } return digitsL ; }
converts number to string without 0 termination - returns number of characters written
converts number to string without 0 termination - returns number of characters written
/* count #digits */