Re: Floating point arithmetic.

From: Subhash (subhash_daga_at_yahoo.com)
Date: 07/11/04


Date: 11 Jul 2004 08:01:32 -0700

Amit Bhatia <bhatia2@nospam.com> wrote in message news:<ccqf0m$lfj$2@news.ks.uiuc.edu>...
> Hi there.
> I am cross posting this on comp.lang.c as well: sorry for same.
> The problem I am facing is as follows:
> For example:
> double a= 0.15;
> double b=2.4;
> const double VERYTINY =1.e-10;
> I know b/a = 16 and hence the remainder is zero; but I am not
> able to find any suitable thing to encode it into in c.
> for example (fmod(b,a)>VERYTINY) returns true!
> Now for this particular instance, (fmodf(b,a)>VERYTINY)
> does return false.
> But now if
> a=0.15;
> b=4.5;
> then fmodf and fmod both don't help...
>
> any suggestions on this?
> I was pointed to a reference on floating point arithmetic, where they talk
> of ulps etc, but is there a small function or fix to deal with this problem
> available somewhere?
>
> thanks,
> amit.

int main() {
  double a = 0.15;
  double b = 2.4;
  const double VERYTINY =1.e-10;
  printf("%d", (fmod(b,a) > VERYTINY));
  return 0;
}

This gives me false!



Relevant Pages

  • Re: Floating point arithmetic.
    ... > I am restarting this thread as I still can't find a good enough fix for ... > problem I am facing: ... > of ulps etc, but is there a small function or fix to deal with this ...
    (comp.lang.c)
  • Re: NIS Printer Spooler pop ups???
    ... > I am not thrilled to have started a thread about cross posting vs. multiposting. ... > information about a fix for the posted problem, or to ask for clarification in order to ... >>> keep getting constant pop up messages about the printer spooler when I open NIS. ...
    (microsoft.public.windowsxp.general)
  • Floating point arithmetic.
    ... I am cross posting this on comp.lang.c as well: ... The problem I am facing is as follows: ... const double VERYTINY =1.e-10; ... I was pointed to a reference on floating point arithmetic, ...
    (comp.lang.cpp)
  • Re: Open Access Competition For FGW
    ... facing a decade when it will only get worse. ... That is a vast over-generalisation. ... On the Cotswold Line, we've gone from a situation where 15% of services ... If First wanted to fix it, First could have included proposals to ...
    (uk.railway)
  • Re: ASP.NET 2.0-generated Javascript
    ... assuming you are running dotNet 2.0 ... open cmd prompt and type ... that should fix it ... Actually I am facing this problem whenever I click on a button and whenever I entered a text in a text box. ...
    (microsoft.public.dotnet.framework.aspnet)