B
Bo Peng
Dear C++ experts,
I need to store and retrieve a meta information that can be int or
double. The program would be significantly simpler if I can handle two
types uniformly. Right now, I am using a single interface:
void setInfo(double); // store info
double info(); // retrieve info
and use
setInfo(static_cast<double>(a))
and
static_cast<int>(info())
to save and retrieve integers. I have not seen any problem yet but I am
worried that maybe sometimes, 12 can be saved as 11.99999999 and
retrieved as 11.
Many thanks in advance.
Bo
I need to store and retrieve a meta information that can be int or
double. The program would be significantly simpler if I can handle two
types uniformly. Right now, I am using a single interface:
void setInfo(double); // store info
double info(); // retrieve info
and use
setInfo(static_cast<double>(a))
and
static_cast<int>(info())
to save and retrieve integers. I have not seen any problem yet but I am
worried that maybe sometimes, 12 can be saved as 11.99999999 and
retrieved as 11.
Many thanks in advance.
Bo