Math.Round (using the AwayFromZero enumeration) is your friend. On Mon, Oct 19, 2009 at 4:07 PM, Bhargav Patel <[email protected]>wrote:
> > I have same problem with VB.NET > Try out this in simply Immediate window or taking variables > > 1.07+1.0 = 2.0700000000000003 > > Why are precisions after 2.07? > I got some business logic failed because of these calculations > > > On 10/13/09, Peter Smith <[email protected]> wrote: > > Well, we don't really need the code. The OP demonstrates only 8 digits of > > precision. That's a Single. The OP wants 16 digits of precision. That's a > > Double. > > > > Apparently, the OP is trying to use doubles everywhere, but has a single > > somewhere, whether as a constant, or an intermediate result or variable. > > > > Math is hard. > > > > Looking at the WallOfCode, and trying to peer past the VB....t,u.v are > > defined as singles, which is where the precision is lost. But we didn't > need > > to see the code, just needed to remind the OP to read > > http://msdn.microsoft.com/en-us/library/system.single.aspx and > > http://msdn.microsoft.com/en-us/library/system.double.aspx a bit more > > carefully. > > >
