本文整理汇总了C++中EvilNumber::CheckIntegrity方法的典型用法代码示例。如果您正苦于以下问题:C++ EvilNumber::CheckIntegrity方法的具体用法?C++ EvilNumber::CheckIntegrity怎么用?C++ EvilNumber::CheckIntegrity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EvilNumber
的用法示例。
在下文中一共展示了EvilNumber::CheckIntegrity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _Divide
EvilNumber EvilNumber::_Divide( const EvilNumber & val1, const EvilNumber & val2 )
{
EvilNumber result;
// WARNING! There should be NO implicit or explicit use of the 'this' pointer here!
if (val2.mType == val1.mType) {
if (val1.mType == evil_number_float) {
result.mValue.fVal = val1.mValue.fVal / val2.mValue.fVal;
result.mType = evil_number_float;
} else if (val1.mType == evil_number_int) {
// make sure we can do things like 2 / 4 = 0.5f
result.mValue.fVal = double(val1.mValue.iVal) / double(val2.mValue.iVal);
result.mType = evil_number_float;
// check if its possibly an integer
result.CheckIntegrity();
}
} else {
// we assume that the val1 argument type is the opposite of the val2 argument type
if (val1.mType == evil_number_float) {
result.mValue.fVal = val1.mValue.fVal / double(val2.mValue.iVal);
result.mType = evil_number_float;
} else if (val1.mType == evil_number_int) {
double tVal = (double)val1.mValue.iVal; // normal integer number
result.mValue.fVal = tVal / val2.mValue.fVal;
result.mType = evil_number_float;
} else {
assert(false); // crash
}
// check if we are an integer
result.CheckIntegrity();
}
return result;
}
示例2: _Modulus
EvilNumber EvilNumber::_Modulus( const EvilNumber & val1, const EvilNumber & val2 )
{
EvilNumber result;
// WARNING! There should be NO implicit or explicit use of the 'this' pointer here!
if (val2.mType == val1.mType) {
if (val1.mType == evil_number_float) {
result.mValue.iVal = (int64)(val1.mValue.fVal) % (int64)(val2.mValue.fVal);
result.mType = evil_number_int;
} else if (val1.mType == evil_number_int) {
result.mValue.iVal = val1.mValue.iVal % val2.mValue.iVal;
result.mType = evil_number_int;
}
} else {
// we assume that the val1 argument type is the opposite of the val2 argument type
if (val1.mType == evil_number_float) {
result.mValue.iVal = (int64)(val1.mValue.fVal) % val2.mValue.iVal;
result.mType = evil_number_int;
} else if (val1.mType == evil_number_int) {
result.mValue.iVal = val1.mValue.iVal % (int64)(val2.mValue.fVal);
result.mType = evil_number_int;
} else {
assert(false); // crash
}
// check if we are a integer
result.CheckIntegrity();
}
return result;
}
示例3: _Subtract
EvilNumber EvilNumber::_Subtract( const EvilNumber & val1, const EvilNumber & val2 )
{
EvilNumber result;
// WARNING! There should be NO implicit or explicit use of the 'this' pointer here!
if (val2.mType == val1.mType) {
if (val1.mType == evil_number_float) {
result.mValue.fVal = val1.mValue.fVal - val2.mValue.fVal;
result.mType = evil_number_float;
} else if (val1.mType == evil_number_int) {
result.mValue.iVal = val1.mValue.iVal - val2.mValue.iVal;
result.mType = evil_number_int;
}
} else {
// we assume that the val argument is the opposite of the 'this' type
if (val1.mType == evil_number_float) {
result.mValue.fVal = val1.mValue.fVal - double(val2.mValue.iVal);
result.mType = evil_number_float;
} else if (val1.mType == evil_number_int) {
double tVal = (double)val1.mValue.iVal; // normal integer number
result.mValue.fVal = tVal - val2.mValue.fVal;
result.mType = evil_number_float;
} else {
assert(false); // crash
}
// check if we are a integer
result.CheckIntegrity();
}
return result;
}