vendredi 19 avril 2019

Is there a way to construct a constexpr function to get bit representation of a double?

Is there a standard way to construct a constexpr function that allows conversion of double to it's 64 bit representation:

constexpr uint64_t double_to_uint64_t(double d) {
   ??????
}

So that

constexpr uint64_t two_bits = double_to_uint64_t(2.0);

would compile?

The reverse method (uint64 to double) is also of interest.

Aucun commentaire:

Enregistrer un commentaire