Skip to content

bug: the scale of the exponential value is zero #16

@lucabart97

Description

@lucabart97

Description

In the code, the scale is set to scalar_type(1/2) when the exponential value is used. This is to ensure that there is a compile-time conversion between the scalar type of the class and the scalar type of the exponential value. However, this can cause an issue because the value is computed at compile time with integer division, which result zero.

Position

You can find this issue in the code by searching for scalar_type(1/2). The issue is ever present in the exponential computation.

Small test

#include <iostream>
template <class scale_type> class Test {
public:
  Test() { std::cout << scale_type(1 / 2) << ' '; }
};

int main() {
  Test<int> t0;
  Test<float> t1;
  Test<double> t2;
  return 0;
}

Result:

0 0 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions