Skip to content

Incorrect const float values in xvalues.cpp files #1059

Description

@maksqwe

Incorerct const float values in x_values.cpp files?

There are several constants from xfvalues.cpp, xlvalues.cpp, xvalues.cpp:

extern const float _FXbig = (NBITS + 1) * 347L / 1000;
extern const double _Xbig = (NBITS + 1) * 347L / 1000;
extern const long double _LXbig = (NBITS + 1) * 347L / 1000;

A diffrerence only in NBITS value and result type.
But all this constants (_FXbig, _Xbig, _LXbig) ignores fractional part.
for example:
extern const float _FXbig = (NBITS + 1) * 347L / 1000; // _FXbig == 8.0f;

In fact _FXbig should equel to 8.32800... if use cast to float:
extern const float _FXbig = static_cast<float>(NBITS + 1) * 347L / 1000;

This values are used to calculate sin(complex)/cos(complex): xlsinh.cpp

_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LSinh(long double x, long double y) {
    // compute y * sinh(x), |y| <= 1
	...
    default: // finite
		...
        if (x < _LRteps._Long_double) {
            x *= y; // x tiny
        } else if (x < 1.0L) {
            long double w = x * x;
            x += x * w * _LPoly(w, p, NP - 1);
            x *= y;
        } else if (x < _LXbig) { // worth adding in exp(-x)
            _LExp(&x, 1.0L, -1);
            x = y * (x - 0.25L / x);
        } else {
		...
    }
	...
}

Because I have not test cases to check, I just reported this issue as a question.
Does the loss of accuracy affect the result?
statementreply

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions