当前位置: 首页>>代码示例>>C++>>正文


C++ EvilNumber::CheckIntegrity方法代码示例

本文整理汇总了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;
}
开发者ID:Almamu,项目名称:evemu_server,代码行数:34,代码来源:EvilNumber.cpp

示例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;
}
开发者ID:Almamu,项目名称:evemu_server,代码行数:30,代码来源:EvilNumber.cpp

示例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;
}
开发者ID:Almamu,项目名称:evemu_server,代码行数:31,代码来源:EvilNumber.cpp


注:本文中的EvilNumber::CheckIntegrity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。