1

I'm not aware and cannot quicly find the right way to enter floating point constant in C++.

If i want 2^-52, what should i write ? And, what does << with float ? Is that correct ?

const double pres = 1>>52
Enjolras
  • 371
  • 2
  • 8

3 Answers3

5

Looks like you really want the precision of double representation. In this case, don't use magic constants. Instead you can use this:

const double pres = std::numeric_limits<double>::epsilon();
Henrik
  • 23,186
  • 6
  • 42
  • 92
3

You can use hex float representation for this:

const double pres = 0x1p-52;
Paul R
  • 208,748
  • 37
  • 389
  • 560
0
#include<math.h>
double pres = 1/pow(2,52);
rosjo
  • 33
  • 5