when using softfloat.. I'm extract the value 3.14f
here is code.. converting value 3.14f for testing with reinterpret_cast
using softfloat, the variabbble of data and data2 value mean 3.14f
I'm using VS 2022 compilier.
typedef unsigned long long uint64_t;
typedef struct { uint64_t v[2]; } float128_t;
typedef struct { uint64_t v; } float64_t;
int main()
{
float128_t data;
data.v[0] = 0x00000070507fe4d8;
data.v[1] = 4611846459178876928;
float64_t data2;
data2.v = 4614253070451212288;
auto test = *reinterpret_cast<double*>(&data.v[0]);
auto test2 = *reinterpret_cast<double*>(&data.v[1]);
auto test3 = *reinterpret_cast<double*>(&data);
auto ans = *reinterpret_cast<double*>(&data2.v);
std::cout << test << " " << test2 << " " << test3 << " " << ans << "\n";
}
in this case, the output is 2.38331e-312 2.07125 2.38331e-312 3.14
Why variable test, test2, test3 not convert correct float value 3.14f ?
why using float64_t type and convert casting that correctly?
does no way to using float128_t type and convert casting that correctly?