Re: weird problem

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: David Lowndes (davidl_at_example.invalid)
Date: 03/07/04


Date: Sun, 07 Mar 2004 21:46:05 +0000


>yes there is, that's probably the problem, but how to solve it?

The solution really depends on your application. If you can do without
floating point values, then do so. Stick with integers, scale them
appropriately if you need to maximise accuracy.

If you can't avoid floating point values, and you want an integer
value, then at some point you have to round the value. Depending on
your requirement, you may need to round down (which is the default
behaviour and what's happened in your current situation), or round to
the nearest integer. Have a look at the _controlfp function, or
implement the rounding yourself as suggested by the other poster.

Dave

-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq


Relevant Pages

  • Re: Double data Type Problem
    ... Great tutorial on IEEE representation. ... of floating point numbers. ... There is just one caution to using the Round function... ... calculation using something known as Banker's Rounding... ...
    (microsoft.public.vb.general.discussion)
  • Re: Double data Type Problem
    ... of floating point numbers. ... 0.001 etc cannot be exactly represented as binary fractions. ... There is just one caution to using the Round function... ... calculation using something known as Banker's Rounding... ...
    (microsoft.public.vb.general.discussion)
  • Re: Problem With Round Function
    ... I read where they are improving accuracy of floating point ... "Ronald W. Roberts" wrote: ... >> I'm having a problem understanding the Round function. ... >> Num DecPt Answer ...
    (microsoft.public.dotnet.languages.vb)
  • Re: a print bug?
    ... however, in the second line, when it is round off, it doesn't know it ... exactly in radix-2 floating point arithmetic. ... 11th decimal point with a subsequent rounding off to the 3rd decimal ... the floating point imperfection is manifested. ...
    (comp.lang.python)
  • Re: Very weird resolution issue. Bug ????? Seriously !!
    ... that at the abstract machine does one operation at a time; the standards contain no ... In C, floating point calculations ... Or the computer is implementing "round alternately" ... always round 1/2 ULP "down", then the consistency of the rounding leads to a cumulative ...
    (comp.soft-sys.matlab)