commit 2025-10-09 12:43 add ZftTrimDecimalZero() ZCppMain/ZMainHead.H

This commit is contained in:
2025-10-09 12:43:06 +09:00
parent b58796277d
commit 22acd30baa
4 changed files with 70 additions and 57 deletions

View File

@ -3706,6 +3706,70 @@ namespace ZNsMain
#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)*/
// 절대값을 가져온다.