コード例 #1
0
ファイル: NNumber.cpp プロジェクト: x414e54/nano
//============================================================================
//		NNumber::GetSInt16 : Get a SInt16 value.
//----------------------------------------------------------------------------
SInt16 NNumber::GetSInt16(void) const
{


	// Get the value
	return((SInt16) GetSInt64());
}
コード例 #2
0
ファイル: NNumber.cpp プロジェクト: x414e54/nano
//============================================================================
//		NNumber::GetSInt32 : Get a SInt32 value.
//----------------------------------------------------------------------------
SInt32 NNumber::GetSInt32(void) const
{


	// Get the value
	return((SInt32) GetSInt64());
}
コード例 #3
0
ファイル: NNumber.cpp プロジェクト: x414e54/nano
//============================================================================
//		NNumber::GetSInt8 : Get a SInt8 value.
//----------------------------------------------------------------------------
SInt8 NNumber::GetSInt8(void) const
{


	// Get the value
	return((SInt8) GetSInt64());
}
コード例 #4
0
ファイル: NNumber.cpp プロジェクト: x414e54/nano
//============================================================================
//		NNumber::GetUInt64 : Get a UInt64 value.
//----------------------------------------------------------------------------
UInt64 NNumber::GetUInt64(void) const
{


	// Get the value
	return((UInt64) GetSInt64());
}
コード例 #5
0
ファイル: NCFNumber.cpp プロジェクト: x414e54/nano
//============================================================================
//		NCFNumber::GetObject : Get the object.
//----------------------------------------------------------------------------
NCFObject NCFNumber::GetObject(void) const
{	Float64			valueFloat64;
	Float32			valueFloat32;
	SInt64			valueSInt64;
	NCFObject		theObject;



	// Get the object
	switch (GetPrecision()) {
		case kNPrecisionInt8:
		case kNPrecisionInt16:
		case kNPrecisionInt32:
		case kNPrecisionInt64:
			valueSInt64 = GetSInt64();
			theObject.SetObject(CFNumberCreate(kCFAllocatorNano, kCFNumberLongLongType, &valueSInt64));
			break;
		
		case kNPrecisionFloat32:
			valueFloat32 = GetFloat32();
			theObject.SetObject(CFNumberCreate(kCFAllocatorNano, kCFNumberFloatType,    &valueFloat32));
			break;
		
		case kNPrecisionFloat64:
			valueFloat64 = GetFloat64();
			theObject.SetObject(CFNumberCreate(kCFAllocatorNano, kCFNumberDoubleType,   &valueFloat64));
			break;
		
		default:
			NN_LOG("Unable to convert '%@' to CFNumber", GetString());
			break;
		}

	return(theObject);
}
コード例 #6
0
Float64	CACFNumber::GetFixed64() const
{
	SInt64 theFixedValue = GetSInt64();
	
	//	this is a 32.32 value so convert it to a double
	Float64 theSign = theFixedValue < 0 ? -1.0 : 1.0;
	theFixedValue *= (SInt64)theSign;
	Float64 theWholePart = (theFixedValue & 0x7FFFFFFF00000000LL) >> 32;
	Float64 theFractPart = theFixedValue & 0x00000000FFFFFFFFLL;
	theFractPart /= 4294967296.0;
	
	return theSign * (theWholePart + theFractPart);
}
コード例 #7
0
ファイル: NNumber.cpp プロジェクト: x414e54/nano
//============================================================================
//		NNumber::Compare : Compare the value.
//----------------------------------------------------------------------------
NComparison NNumber::Compare(const NNumber &theValue) const
{	Float64				valueFloat64_1, valueFloat64_2;
	Float32				valueFloat32_1, valueFloat32_2;
	SInt64				valueInt64_1,  valueInt64_2;
	NComparison			theResult;



	// Compare equal types
	if (mPrecision == theValue.mPrecision || (IsInteger() && theValue.IsInteger()))
		{
		switch (mPrecision) {
			case kNPrecisionInt8:
			case kNPrecisionInt16:
			case kNPrecisionInt32:
			case kNPrecisionInt64:
				theResult = GetComparison(mValue.integer, theValue.mValue.integer);
				break;
			
			case kNPrecisionFloat32:
				valueFloat32_1 = (Float32)          mValue.real;
				valueFloat32_2 = (Float32) theValue.mValue.real;
				theResult      = GetComparison(valueFloat32_1, valueFloat32_2);
				break;

			case kNPrecisionFloat64:
				theResult = GetComparison(mValue.real, theValue.mValue.real);
				break;

			default:
				NN_LOG("Unknown precision: %d", mPrecision);
				theResult = kNCompareLessThan;
				break;
			}
		}


	// Compare dis-similar types
	else
		{
		switch (mPrecision) {
			case kNPrecisionInt8:
			case kNPrecisionInt16:
			case kNPrecisionInt32:
			case kNPrecisionInt64:
				valueInt64_1 =          GetSInt64();
				valueInt64_2 = theValue.GetSInt64();
				theResult    = GetComparison(valueInt64_1, valueInt64_2);
				break;

			case kNPrecisionFloat32:
				valueFloat32_1 =          GetFloat32();
				valueFloat32_2 = theValue.GetFloat32();
				theResult      = GetComparison(valueFloat32_1, valueFloat32_2);
				break;

			case kNPrecisionFloat64:
				valueFloat64_1 =          GetFloat64();
				valueFloat64_2 = theValue.GetFloat64();
				theResult      = GetComparison(valueFloat64_1, valueFloat64_2);
				break;

			default:
				NN_LOG("Unknown precision: %d", mPrecision);
				theResult = kNCompareLessThan;
				break;
			}
		}

	return(theResult);
}