Skip to content

Found a bug in libm.so.6 in centos7.9.2009 image #201

@aqluheng

Description

@aqluheng

When I run this code on a CentOS 7 image, I get an incorrect result.

#include <iostream>
#include <cmath>
#include <iomanip>

int main() {
    long double num1 = 20010999999.9999990905052982270717621L;
    std::cout << std::fixed  << std::setprecision(20) << "std::round(" << num1 << ") = " << std::round(num1) << std::endl;

    return 0;
}
// (centos7): std::round(20010999999.99999909050529822707) = 20010999999.999999090505298227

I found that this task should be associated with the roundl function in libm.so.6. After modifying this function as follows, the code runs correctly.

-cmp     w19, #0x1e
+cmp     w19, #0x2f

Could this modification be incorporated into the CentOS 7.9 image?

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