0

Related to this question: Printf width specifier to maintain precision of floating-point value.

I want to print the significant digits of a number n represented using a double d as n = 2^d. Is there a function of d which computes the significant digits of n? A maximum number (larger than 0) for the significant digits is also fine, like DBL_DIG in float.h.

Edit: I will be doing many additions to d such that 2^d >> MAX_DOUBLE. I suspect therefore the number of significant digits in n will be less than the significant digits of d. Is this true? By addition I mean (hopefully this makes sense):

Let n = n1 + n2, n1 = 2^d1, n2 = 2^d2 then I will perform d = d1 + d2, such that n = 2^d.

The reason I am using this is because it is nearly impossible to let d overflow and I am fine with loosing lots of precision in n.

I will be using a function described here: http://buddy.sourceforge.net/manual/group__info_ge551a6cc544c7d50a3d7c7fb7f5f9374.html#ge551a6cc544c7d50a3d7c7fb7f5f9374.

meijuh
  • 1,067
  • 1
  • 9
  • 23

0 Answers0