Article View: alt.pl.comp.lang.csharp
Article #432Re: divide operation precision is changing
From: Marek Janaszewski USUNTO. z adre...
Date: Tue, 20 Jan 2004 23:20
Date: Tue, 20 Jan 2004 23:20
39 lines
2185 bytes
2185 bytes
W artykule news:400d4213$1...@news.012.net.il, niejaki(a): Maor Mishkin z adresu <ju...@omnivee.com> napisaล(a): > I have a problem with divide operation, > the example is: > double a =10.0; > double b =220.0; > double divAns = a/b; > the calculation true result is 0.04545454545454545 > but for some resone the calculation is changing to get the result > 0.0454545468091 > if you know how can i get the system to calc the first calculation or > if you know of an object like BigNumber in java that can make > calculation with a specipic precision it could realy help me alot. > Maor Hi, I think it problem with floating point numbers. Floating-point numbers stores numbers approximately. For example, floating-point types don't precisely represent 0.1. Try to use "decimal" type. Decimal type should by used in financial calculations. You can find more information about floating-point number at: http://www.research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html http://www.mathworks.com/company/newsletter/pdf/Fall96Cleve.pdf http://developer.intel.com/design/intarch/techinfo/pentium/fpu.htm PS Sorry for my English. -- Regards, Marek Janaszewski [ j_m...@gazeta.pl ]
Technical Details
Message-ID:
<bukddm$k51$1@SunSITE.icm.edu.pl>Path:
mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed.gazeta.pl!news.icm.edu.pl!not-for-mailReferences:
<400d4213$1@news.012.net.il>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed.gazeta.pl!news.icm.edu.pl!not-for-mail From: "Marek Janaszewski \(USUN_TO. z adresu!\)" <USUN_TO...@gazeta.pl> Newsgroups: alt.pl.comp.lang.csharp Subject: Re: divide operation precision is changing Date: Wed, 21 Jan 2004 00:20:20 +0100 Organization: http://news.icm.edu.pl/ Lines: 40 Message-ID: <bukddm$k51$1@SunSITE.icm.edu.pl> References: <400d4213$1@news.012.net.il> NNTP-Posting-Host: systemy169.toya.net.pl Mime-Version: 1.0 X-Trace: SunSITE.icm.edu.pl 1074641142 20641 217.113.225.169 (20 Jan 2004 23:25:42 GMT) X-Complaints-To: ab...@icm.edu.pl NNTP-Posting-Date: Tue, 20 Jan 2004 23:25:42 +0000 (UTC) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MSMail-Priority: Normal Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit