【问题标题】:Horner's rule using fixed point arithmetic in C在 C 中使用定点算术的霍纳规则
【发布时间】:2017-11-01 11:32:50
【问题描述】:

我很难使用定点算法来追踪这个遵循霍纳规则的小数点。

int16_t horner(int16_t q)
{
    const int16_t c0 = 0x0033;
    const int16_t c1 = 0x0055;
    const int16_t c2 = 0x001C;
    const int16_t c3 = 0x0048;
    const int16_t c4 = 0x0200;

    horner_rule = c0 + q * (c1 - q * (c2 + q * (c3 - q * c4)));

    return horner_rule;
}

其中c0c1是不同的 16 位有符号系数,q 是我想要评估的值(q 被视为输入并转换为 16 位有符号格式)。所有这些值都已转换为带符号的 16 位格式。我已经用浮点算法实现了这个,它工作得很好。

我的问题是,我应该如何继续获得我想要的值来保持小数点并控制溢出?

【问题讨论】:

    标签: c math fixed-point


    【解决方案1】:

    首先要确定多项式和部分多项式的域和余域。然后您可以调整班次以最大限度地减少截断错误,同时避免溢出。

    如果您需要自动执行此过程,则必须找到所有这些多项式的最小值和最大值,这需要求解实根。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-25
      • 2014-11-13
      相关资源
      最近更新 更多