Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Meaning of "most significant digits" in the printf documentation (http://www.velocityreviews.com/forums/t515012-meaning-of-most-significant-digits-in-the-printf-documentation.html)

Mukesh_Singh_Nick@yahoo.com 06-16-2007 11:05 AM

Meaning of "most significant digits" in the printf documentation
 
What is meant by the "most significant digits" in the following
statement?

<BLOCKQUOTE>
With %g and %G, the precision modifier determines the maximum number
of significant digits displayed.</BLOCKQUOTE>

The statement appears here: http://www.cppreference.com/stdio/printf.html

Also, what do we mean by the magnitude of a floating point number?

I understand that the magnitude of an integral is equal to its
absolute value. However, I do not understand the meaning of the
magnitude of a floating point.

For a citation, please note the sentence below:

<BLOCKQUOTE>A float number is typically a 32-bit quantity, with at
least six significant digits and magnitude generally between about
10^(-38) and 10^(+38).</BLOCKQUOTE>

Source: K & R, Page 9, Second Edition


Ben Bacarisse 06-16-2007 12:07 PM

Re: Meaning of "most significant digits" in the printf documentation
 
Mukesh_Singh_Nick@yahoo.com writes:

> What is meant by the "most significant digits" in the following
> statement?
>
> <BLOCKQUOTE>


Don't bother with markup like this. Usenet news is a plain text
medium. People sometimes use markers for humorous effect
(e.g. <sarcasm>really?</sarcasm>) but don't try to effect the llok of
your post with HTML or similar.

> With %g and %G, the precision modifier determines the maximum number
> of significant digits displayed.</BLOCKQUOTE>


You say "most" at the top but the quote has "maximum" so I am i bit
confused about what is bothering you. The precision determines how
much of number gets represented. Obviously only the most significant
digits are used but you can say "no more than X digits". There may
be other stuff printed, because %g might use scientific notation, but
the precision limits the number of significant digits printed. The
number you give is a maximum because fewer may be sufficient:

4.0e30 using %.3g prints "4e+30"
4.3e30 using %.1g prints "4e+30"
4.3e30 using %.2g prints "4.1e+30"

> The statement appears here:
> http://www.cppreference.com/stdio/printf.html


Look like a C++ reference. This may lead you astray if you are using
it for C. Read the C FAQ instead: http://c-faq.com/

> Also, what do we mean by the magnitude of a floating point number?
>
> I understand that the magnitude of an integral is equal to its
> absolute value. However, I do not understand the meaning of the
> magnitude of a floating point.


It usually means exactly the same -- the absolute value. It certainly
does in the quote you cite from K&R:

> A float number is typically a 32-bit quantity, with at
> least six significant digits and magnitude generally between about
> 10^(-38) and 10^(+38).
>
> Source: K & R, Page 9, Second Edition


--
Ben.

Chris Torek 06-17-2007 01:24 AM

Re: Meaning of "most significant digits" in the printf documentation
 
In article <1181991919.539585.223790@i38g2000prf.googlegroups .com>
<Mukesh_Singh_Nick@yahoo.com> wrote:
>What is meant by the "most significant digits" in [printf %g formats]


Actually, it is just "significant digits", with no "most"
qualifier.

For much about this and about your earlier question about floating
point, see <http://web.torek.net/torek/c/numbers.html>.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (4039.22'N, 11150.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.


All times are GMT. The time now is 03:49 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.