41 lines
772 B
C++
41 lines
772 B
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TNumeric Àà
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TNumeric ÀඨÒå
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TNumeric.h"
|
|
|
|
TNumeric::TNumeric(double dVal, double dPrec)
|
|
: nValue(dVal), nPrec(dPrec)
|
|
{
|
|
|
|
}
|
|
|
|
TNumeric::~TNumeric()
|
|
{
|
|
|
|
}
|
|
|
|
int TNumeric::AsInt()
|
|
{
|
|
// È¡ÕûÊý²¿·Ö
|
|
int iVal = (int)nValue;
|
|
double fVal = nValue - iVal;
|
|
if (fabs(fVal - 1.0) < nPrec)
|
|
{
|
|
iVal ++;
|
|
}
|
|
else if( fabs(fVal + 1.0) < nPrec)
|
|
{
|
|
iVal --;
|
|
}
|
|
|
|
return iVal;
|
|
}
|