The function pow of math returns several results in several versions of Fedora


I’m developing a program in C++. I have to perform some calculations with pow of math library. When a run this code:

#include <math.h>
#include <stdio.h>

int main (void)
unsigned long l;
double d1,d2,d3;

l = 13831305406817642647;
d1 = 2.;
d2 = ((double)(&l));
d3 = pow(d1,d2);
printf (“%lu,%20.20f\n”,*((unsigned long )(&d1)),d1);
printf (“%lu,%20.20f\n”,
((unsigned long )(&d2)),d2);
printf (“%lu,%20.20f\n”,
((unsigned long *)(&d3)),d3);

return 0;

With Fedora 35 I obtain:


But with Fedora 36:


I converted the doubles to a binary image of unsigned long to detect any change for just one bit.

In the third line you can observe this kind of change. Why I obtain a different result when I calculate over the same values with pow?

The full information about the version of Fedora (obtained with uname -r):

For Fedora 35: 5.17.11-200.fc35.x86_64
For Fedora 36: 5.17.0-0.rc7.116.fc36.x86_64

Any help will be welcome.

This is probably because of floating point arithmetic. The versions of compilers are also different, so that could cause it too: Fedora 35 has version 11, while Fedora 36 now has version 12: