문제

What is a good way to create a double from a coefficient and a power of 10? Or in other words, what is a good way to create a double from the significand and the exponent of a written scientific notation value at runtime?

도움이 되었습니까?

해결책

Not sure about numerical quality, but the obvious way would be:

double make_double(double coefficient, int power)
{
  return coefficient * pow(10.0, power);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top