commit 2025-10-09 12:43 add ZftTrimDecimalZero() ZCppMain/ZMainHead.H
This commit is contained in:
@ -3706,6 +3706,70 @@ namespace ZNsMain
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template
|
||||||
|
<typename TTypChar, typename TTypLength>
|
||||||
|
static TTypChar* ZftTrimDecimalZero
|
||||||
|
(TTypChar* APC_Data, TTypLength& ARRI_Length)
|
||||||
|
{
|
||||||
|
/* 문자열 APC_Data 이 어떤 소수를 표현할 경우
|
||||||
|
소수점 뒤에 맨 끝에 있는 의미없는 0 을 지운다.
|
||||||
|
*/
|
||||||
|
typedef TTypChar TypeChar ;
|
||||||
|
typedef TTypLength TypeLength ;
|
||||||
|
|
||||||
|
TypeChar* VPC_StartChar= APC_Data;
|
||||||
|
|
||||||
|
if(ARRI_Length<=0)
|
||||||
|
{ ARRI_Length=0; return 0; }
|
||||||
|
|
||||||
|
TypeLength VL_PeriodPos =0;
|
||||||
|
TypeLength VL_CurrentPos=0;
|
||||||
|
|
||||||
|
for(; VL_PeriodPos<ARRI_Length; ++VL_PeriodPos)
|
||||||
|
{
|
||||||
|
if( *VPC_StartChar++ =='.' ) break;
|
||||||
|
}
|
||||||
|
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
|
||||||
|
|
||||||
|
// 마침표가 없거나, 맨 앞에 오거나 맨 끝에 오는 경우도 유효하지 않다.
|
||||||
|
|
||||||
|
if(VL_PeriodPos<1 || VL_PeriodPos>=ARRI_Length-1)
|
||||||
|
{ return APC_Data; }
|
||||||
|
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
|
||||||
|
|
||||||
|
|
||||||
|
VPC_StartChar = APC_Data +
|
||||||
|
( VL_CurrentPos = ARRI_Length-1 ) ;
|
||||||
|
|
||||||
|
while(VL_PeriodPos<VL_CurrentPos)
|
||||||
|
{
|
||||||
|
if(*VPC_StartChar!=TypeChar('0'))
|
||||||
|
{ break; }
|
||||||
|
/*+++++++++++++++++++++++++++++*/
|
||||||
|
|
||||||
|
*VPC_StartChar=0;
|
||||||
|
|
||||||
|
--VL_CurrentPos;
|
||||||
|
--VPC_StartChar;
|
||||||
|
--ARRI_Length ;
|
||||||
|
}/*
|
||||||
|
while(VL_PeriodPos<VL_CurrentPos)*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 소수부 맨 끝에 0 을 삭제한 결과,
|
||||||
|
마침표가 끝에 온다면 그 마침표도 지운다.
|
||||||
|
*/
|
||||||
|
if(VL_PeriodPos==VL_CurrentPos)
|
||||||
|
{ * VPC_StartChar =TypeChar(0); --ARRI_Length; }
|
||||||
|
else{ *(VPC_StartChar+1)=TypeChar(0); }
|
||||||
|
|
||||||
|
return APC_Data; /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
||||||
|
}/*
|
||||||
|
template
|
||||||
|
<typename TTypChar, typename TTypLength>
|
||||||
|
static TTypChar* ZftTrimDecimalZero
|
||||||
|
(TTypChar* APC_Data, TTypLength& ARRI_Length)*/
|
||||||
|
|
||||||
|
|
||||||
// 절대값을 가져온다.
|
// 절대값을 가져온다.
|
||||||
|
|
||||||
|
@ -1694,6 +1694,8 @@ namespace ZNsMain
|
|||||||
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%f", AD_DoubleParam)
|
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%f", AD_DoubleParam)
|
||||||
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%f", AD_DoubleParam)
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%f", AD_DoubleParam)
|
||||||
);
|
);
|
||||||
|
ZNsMain::ZftTrimDecimalZero(VCA_BuffParam, RR(VI_ResultSize));
|
||||||
|
|
||||||
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
||||||
}/*
|
}/*
|
||||||
ZCStringBase& operator()(double AD_DoubleParam)*/
|
ZCStringBase& operator()(double AD_DoubleParam)*/
|
||||||
@ -6476,59 +6478,6 @@ namespace ZNsMain
|
|||||||
}/*
|
}/*
|
||||||
ZCStringBase& Trim()*/
|
ZCStringBase& Trim()*/
|
||||||
|
|
||||||
static TypeChar* TrimDecimalZero(TypeChar* APC_Data, TypeLength AI_LengthDec=-1)
|
|
||||||
{
|
|
||||||
/* 문자열 APC_Data 이 어떤 소수를 표현할 경우
|
|
||||||
소수점 뒤에 맨 끝에 있는 의미없는 0 을 지운다. */
|
|
||||||
|
|
||||||
TypeChar* VPC_StartChar=APC_Data;
|
|
||||||
|
|
||||||
if(AI_LengthDec<0)
|
|
||||||
{
|
|
||||||
AI_LengthDec = GetLength(APC_Data) ;
|
|
||||||
}/*
|
|
||||||
if(AI_LengthDec<0)*/
|
|
||||||
|
|
||||||
if(AI_LengthDec<1) return 0;
|
|
||||||
|
|
||||||
TypeLength VL_PeriodPos =0;
|
|
||||||
TypeLength VL_CurrentPos=0;
|
|
||||||
|
|
||||||
for(; VL_PeriodPos<AI_LengthDec; ++VL_PeriodPos)
|
|
||||||
{
|
|
||||||
if( *VPC_StartChar++ =='.' ) break;
|
|
||||||
}/*
|
|
||||||
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
|
|
||||||
|
|
||||||
// 마침표가 없거나, 맨 앞에 오거나 맨 끝에 오는 경우도 유효하지 않다.
|
|
||||||
|
|
||||||
if(VL_PeriodPos<1 || VL_PeriodPos>=AI_LengthDec-1)
|
|
||||||
{ return APC_Data; }
|
|
||||||
//////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
VPC_StartChar = APC_Data +
|
|
||||||
( VL_CurrentPos = AI_LengthDec-1 ) ;
|
|
||||||
|
|
||||||
while(VL_PeriodPos<VL_CurrentPos)
|
|
||||||
{
|
|
||||||
if(*VPC_StartChar!='0') break;
|
|
||||||
|
|
||||||
*VPC_StartChar=0;
|
|
||||||
|
|
||||||
--VL_CurrentPos;
|
|
||||||
--VPC_StartChar;
|
|
||||||
}/*
|
|
||||||
while(VL_PeriodPos<VL_CurrentPos)*/
|
|
||||||
|
|
||||||
|
|
||||||
/* 소수부 맨 끝에 0 을 삭제한 결과 마침표가 끝에 온다면 그 마침표도 지운다. */
|
|
||||||
|
|
||||||
if(VL_PeriodPos==VL_CurrentPos) *VPC_StartChar=0;
|
|
||||||
|
|
||||||
return APC_Data; /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
|
|
||||||
}/*
|
|
||||||
static TypeChar* TrimDecimalZero(TypeChar* APC_Data, TypeLength AI_Length=-1)*/
|
|
||||||
|
|
||||||
ZCStringBase& TrimDecimalZero()
|
ZCStringBase& TrimDecimalZero()
|
||||||
{
|
{
|
||||||
@ -6574,9 +6523,7 @@ namespace ZNsMain
|
|||||||
{
|
{
|
||||||
*VPC_StartChar=0; --ml_UseLen;
|
*VPC_StartChar=0; --ml_UseLen;
|
||||||
}
|
}
|
||||||
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
|
return *this; /*+++++++++++++*/
|
||||||
|
|
||||||
return *this;
|
|
||||||
}/*
|
}/*
|
||||||
ZCStringBase& TrimDecimalZero()*/
|
ZCStringBase& TrimDecimalZero()*/
|
||||||
|
|
||||||
|
@ -481,6 +481,8 @@ namespace ZNsMain
|
|||||||
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%f", AD_DoubleParam)
|
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%f", AD_DoubleParam)
|
||||||
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%f", AD_DoubleParam)
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%f", AD_DoubleParam)
|
||||||
);
|
);
|
||||||
|
ZNsMain::ZftTrimDecimalZero(VCA_BuffParam, RR(VI_ResultSize));
|
||||||
|
|
||||||
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
||||||
}/*
|
}/*
|
||||||
ZtCStringStd& operator()(double AD_DoubleParam)*/
|
ZtCStringStd& operator()(double AD_DoubleParam)*/
|
||||||
|
@ -137,7 +137,7 @@ namespace ZNsMain
|
|||||||
ZftMakeStr(VO_ZCStringStd, ZCCharView("_Z_"));
|
ZftMakeStr(VO_ZCStringStd, ZCCharView("_Z_"));
|
||||||
|
|
||||||
|
|
||||||
cout<<"* after ZftMakeStr()"<<endl;
|
cout<<"* after ZftMakeStr(VO_ZCStringStd, ~)"<<endl;
|
||||||
cout<<"# "<<VO_ZCStringStd<<endl;
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
||||||
cout<<"*****************************************************"<<endl;
|
cout<<"*****************************************************"<<endl;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user