Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Stringification of FP numbers.

by ig (Vicar)
on Jun 12, 2009 at 17:26 UTC ( [id://771034]=note: print w/replies, xml ) Need Help??


in reply to Stringification of FP numbers.

The conversion is usually done by gconvert(), gcvt() or printf with %g format, depending on what Configure determined and, for example, on CentOS5 the %g format is described as:

The double argument is converted in style f or e (or F or E for G conversions). The precision specifies the number of significant digits. If the precision is missing, 6 digits are given; if the precision is zero, it is treated as 1. Style e is used if the exponent from its conversion is less than -4 or greater than or equal to the precision. Trailing zeros are removed from the fractional part of the result; a decimal point appears only if it is followed by at least one digit.

The emphasis is mine. This is consistent with the result you are seeing.

Replies are listed 'Best First'.
Re^2: Stringification of FP numbers.
by gam3 (Curate) on Jun 14, 2009 at 18:51 UTC
    I think that this is the answer I was looking for. It is dependent on the clib then if %g is being used.

    However %g in a C program gives this output:

    0.0001
    1e-05
    100000
    1e+06
    
    I guess I'll have have to get the source code and look. Thanks.
    -- gam3
    A picture is worth a thousand words, but takes 200K.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://771034]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-18 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found