Group: comp.lang.c++
From: Francogrex
Date: Sunday, April 06, 2008 1:32 PM
Subject: Re: How to compute 1/(2*i)?

On Apr 6, 11:53=A0am, Alan Johnson wrote:
> > the problem is that C++ is not doing this calculation 1/(2*i)
> > correctly. Is there a way to force him to do this division other than
> > using the brackets? Thanks.
>
> 1 and 2 are int literals, and i is defined as an int, so the expression
> 1/(2*i) performs integer division. =A0The easiest way to force floating
> point division is to make one of your literals a floating point number.
> That is: 1/(2.*i)

Hi thanks all. I just figured it out right after I posted. Sometimes
it's worthwhile that I try and be patient before I post.

Safety Articles | Usenet Groups | Usenet News | Bluegrass