Re: weird problem visual c++

From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 03/08/04


Date: Mon, 08 Mar 2004 00:48:32 GMT

Kurt Van Samang wrote:
>
> you were right, the problem was some floating point round off
> which made the value 39.9995 or something, so i added a small
> value to solve this. thx

Please don't toppost. Don't add a small number, you will just
move the error point. Decide how many digits you want, arrange
for that to be the integral part of the float, and add 0.5 before
truncating with a cast or integer assignment.

-- 
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


Relevant Pages

  • 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: 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)
  • Tough problem...
    ... I am hoping somebody here has enough expirience ... in math and floating point round off errors, ...
    (borland.public.delphi.language.basm)
  • Re: Rounding
    ... > Now you gets incorrectly round down. ... Never ever use floatingpoint arithmeting when it is money you ... I already limited the number of lines with floating point math to 1, ...
    (comp.os.os2.programmer.misc)
  • Re: sprintf rouding error
    ... "uncorrectness" with floating point conversion leads to the ... zero"), it doesn't round. ... So there is no error at all in any internal representation of $n+0.5, ... power of 2, e. ...
    (comp.lang.perl.misc)