Вопрос

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