Article View: alt.pl.comp.lang.csharp
Article #21534Problem z dokładnością double??
From: Zeus
Date: Tue, 01 Jun 2010 09:52
Date: Tue, 01 Jun 2010 09:52
23 lines
1462 bytes
1462 bytes
public double modf(double pb, ref double intbase)
{
intbase = (double)((int)(pb));
Console.WriteLine("modf wewint = {0:F10} ", intbase);
double x = pb - intbase;
Console.WriteLine("modf wew = {0} ", x );
return pb - intbase;
}
double ibase, we = 8893.897645320;
double wy = modf(we, ibase);
Dostaję:
modf wewint = 8893.0000000000
modf wew = 0.897645319999356
wy = 0.897645319999356
a powinno być wy = 0.897645320 dla mnie ta niedokładność jest znacząca.
Teoretycznie double ma dokładność do 15 miejsca a tu takie numery już na
8. Co jest grane, piszesz double a on myśli float?
Co zrobić z fantem?. Czy tu bez obaw da się coś policzyć gdy muszę
sprawdzać wynik każdego działania?
Technical Details
Message-ID:
<4C04D85E.3070406@cbk.poznan.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!newsb.icpnet.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!newsb.icpnet.pl!not-for-mail From: Zeus <s.zapasnik@cbk.poznan.pl> Newsgroups: alt.pl.comp.lang.csharp Subject: Problem z dokładnością double?? Date: Tue, 01 Jun 2010 11:52:30 +0200 Organization: ICP News Server Lines: 23 Message-ID: <4C04D85E.3070406@cbk.poznan.pl> NNTP-Posting-Host: c156-41.icpnet.pl Mime-Version: 1.0 X-Trace: opal.icpnet.pl 1275385959 4083 85.221.156.41 (1 Jun 2010 09:52:39 GMT) X-Complaints-To: abuse@icpnet.pl NNTP-Posting-Date: Tue, 1 Jun 2010 09:52:39 +0000 (UTC) User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit