Use more than 5 and you're safe. Something like %.7f that way you would get
a bunch 0s and sometimes some low order decimals. But the important thing
is that the difference is less than 1e-5.

Carlos Guia
On Apr 28, 2012 4:43 PM, "Eric Kulcyk" <[email protected]> wrote:

> Hello,
>
> I had a partial solution for C coded up, however I wasn't sure how to
> format the output correctly.  The problem says the answer for be correct to
> 1E-5, but the sample output is "1.4"
> When I use %.5f or %f, it does 1.40000.  I can get it to print 1.4 with
> %.2g, however 1.45 outputs as 1.5 when using %.2g.  I tried to code a
> solution that detected how many digits were in the solution, but it failed
> for 120.000000000025 (it output 1.2e+02).
>
> What's the correct way to do this?
> BTW, using printf in java using eclipse.
>
> Thanks,
> Eric
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-code/-/colHK14rDqUJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to