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


C++ HNumber类代码示例

本文整理汇总了C++中HNumber的典型用法代码示例。如果您正苦于以下问题:C++ HNumber类的具体用法?C++ HNumber怎么用?C++ HNumber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HNumber类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HNumber

HNumber Functions::Private::bin( Function *, const QVector<HNumber> & args )
{
  if ( args.count() != 1 )
    return HNumber("NaN");

  HNumber result = args[0];
  result.setFormat( 'b' );
  return result;
}
开发者ID:ruphy,项目名称:speedcrunch,代码行数:9,代码来源:functions.cpp

示例2: function_absdev

HNumber function_absdev(Function* f, const Function::ArgumentList& args)
{
    ENSURE_POSITIVE_ARGUMENT_COUNT();
    HNumber mean = function_average(f, args);
    if (mean.isNan())
        return HMath::nan();
    HNumber acc = 0;
    for (int i = 0; i < args.count(); ++i)
        acc += HMath::abs(args.at(i) - mean);
    return acc / HNumber(args.count());
}
开发者ID:mohammadul,项目名称:SpeedCrunch,代码行数:11,代码来源:functions.cpp

示例3: nan

HNumber Functions::Private::lg( Function * f, const QVector<HNumber> & args )
{
  if ( args.count() != 1 )
    return HNumber::nan();

  HNumber x = args[0];
  HNumber result = HMath::lg( x );

  if ( result.isNan() )
    f->setError( f->name(), Functions::tr(
                    "function undefined for specified argument" ) );

  return result;
}
开发者ID:ruphy,项目名称:speedcrunch,代码行数:14,代码来源:functions.cpp

示例4: append

void ResultDisplay::append(const QString& expression, const HNumber& value)
{
    ++m_count;

    appendPlainText(expression);
    if (!value.isNan())
        appendPlainText(QLatin1String("= ") + NumberFormatter::format(value));
    appendPlainText(QLatin1String(""));

    // TODO: Refactor, this only serves to save a session.
    m_expressions.append(expression);
    if (value.isNan()) {
        m_results.append("");
    } else {
        const char format = value.format() != 0 ? value.format() : 'e';
        char* str = HMath::format(value, format, DECPRECISION);
        m_results.append(str);
        free(str);
    }
}
开发者ID:HenriAugusto,项目名称:SpeedCrunch,代码行数:20,代码来源:resultdisplay.cpp

示例5: updateBits

void BitFieldWidget::updateBits(const HNumber& number)
{
    QString binaryNumberString = HMath::format(number, 'b');
    QListIterator<BitWidget*> bitsIterator(m_bitWidgets);

    if (number.isZero() || !number.isInteger())
        binaryNumberString.clear();
    else if (number.isNegative())
        binaryNumberString.remove(0, 3); // Remove '-0b'.
    else
        binaryNumberString.remove(0, 2); // Remove '0b'.

    QString::ConstIterator iterator = binaryNumberString.end();
    while (bitsIterator.hasNext()) {
        if (iterator != binaryNumberString.begin()) {
            --iterator;
            bitsIterator.next()->setState(*iterator == '1');
        } else
            bitsIterator.next()->setState(false);
    }
}
开发者ID:0pq76r,项目名称:SpeedCrunch,代码行数:21,代码来源:bitfieldwidget.cpp

示例6: function_round

HNumber function_round(Function* f, const Function::ArgumentList& args)
{
    ENSURE_EITHER_ARGUMENT_COUNT(1, 2);
    HNumber num = args.at(0);
    if (args.count() == 2) {
        HNumber argPrecision = args.at(1);
        if (argPrecision != 0) {
            if (!argPrecision.isInteger()) {
                f->setError(OutOfDomain);
                return HMath::nan();
            }
            int prec = argPrecision.toInt();
            if (prec)
                return HMath::round(num, prec);
            // The second parameter exceeds the integer limits.
            if (argPrecision < 0)
                return HNumber(0);
            return num;
        }
    }
    return HMath::round(num);
}
开发者ID:mohammadul,项目名称:SpeedCrunch,代码行数:22,代码来源:functions.cpp

示例7: autoCalcSelection

void Editor::autoCalcSelection()
{
    if (!m_isAutoCalcEnabled)
        return;

    const QString str = m_evaluator->autoFix(textCursor().selectedText());
    if (str.isEmpty())
        return;

    // Very short (just one token) and still no calculation, then skip.
    if (!m_isAnsAvailable) {
        const Tokens tokens = m_evaluator->scan(text());
        if (tokens.count() < 2)
            return;
    }

    // Too short even after autofix? Don't bother either.
    const Tokens tokens = m_evaluator->scan(str);
    if (tokens.count() < 2)
        return;

    // Same reason as above, do not update "ans".
    m_evaluator->setExpression(str);
    const HNumber num = m_evaluator->evalNoAssign();

    if (m_evaluator->error().isEmpty()) {
        if (num.isNan() && m_evaluator->isUserFunctionAssign()) {
            // Result is not always available when assigning a user function.
            const QString message = tr("Selection result: n/a");
            emit autoCalcEnabled(message);
        } else {
            const QString message = tr("Selection result: <b>%1</b>").arg(NumberFormatter::format(num));
            emit autoCalcEnabled(message);
        }
    } else
        emit autoCalcEnabled(m_evaluator->error());
}
开发者ID:0pq76r,项目名称:SpeedCrunch,代码行数:37,代码来源:editor.cpp


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