41 lines
759 B
C++
41 lines
759 B
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, SH Software Co. Ltd.
|
|
// = FileName : XNumeric Àà
|
|
// = Version : ver2.0
|
|
// = Author : zjq
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: XNumeric ÀඨÒå
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "XNumeric.h"
|
|
|
|
XNumeric::XNumeric(double dVal, double dPrec)
|
|
: nValue(dVal), nPrec(dPrec)
|
|
{
|
|
|
|
}
|
|
|
|
XNumeric::~XNumeric()
|
|
{
|
|
|
|
}
|
|
|
|
int XNumeric::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;
|
|
}
|