Article View: alt.comp.lang.learn.c-c++
Article #628Re: C++: How to do floating point division?
From: Sunil Rao
Date: Sat, 20 Feb 1999 00:00
Date: Sat, 20 Feb 1999 00:00
25 lines
1615 bytes
1615 bytes
Jim Cobban wrote:
>
> In article <7Riz2.11845$cQ5.6291@nnrp2.clara.net>,
> Jules <julius@clara.net> wrote:
> >Dear all, I want to do a const line like this in C++:
> >
> >const float pi = 22/7;
> >
> >but '/' will only return an int, so how do I have a float to store in pi?
> >
> #include <math.h>
>
> const double pi = M_PI; /* much more accurate */
> ^^^^^^
M_PI is non-standard, though.
--
{ Sunil Rao }
"A boiled egg, you see, is not merely an egg that has been boiled.
It is a self-contained package, an irresistible alliance, of
violence and nursery rhymes. To get into it, you must destroy it."
- Terry Durack in "The Independent on Sunday", as quoted in
"Pseuds Corner" of "Private Eye" magazine!
Technical Details
Message-ID:
<36CEBB65.9DB7E82B@ic.ac.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7Riz2.11845$cQ5.6291@nnrp2.clara.net> <7akkrr$gh5$1@bcarh8ab.ca.nortel.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,e29ff327add874ff X-Google-Attributes: gid109fba,public X-Google-Thread: 143fed,e29ff327add874ff X-Google-Attributes: gid143fed,public X-Google-Thread: 114592,e29ff327add874ff X-Google-Attributes: gid114592,public X-Google-Thread: fb1d5,e29ff327add874ff X-Google-Attributes: gidfb1d5,public From: Sunil Rao <sunil.rao@ic.ac.uk> Subject: Re: C++: How to do floating point division? Date: 1999/02/20 Message-ID: <36CEBB65.9DB7E82B@ic.ac.uk> X-Deja-AN: 446397423 Content-Transfer-Encoding: 7bit References: <7Riz2.11845$cQ5.6291@nnrp2.clara.net> <7akkrr$gh5$1@bcarh8ab.ca.nortel.com> Content-Type: text/plain; charset=us-ascii Organization: ISE @ ic.ac.uk Mime-Version: 1.0 Newsgroups: alt.comp.lang.learn.c-c++,claranet.local.help,claranet.local.tech,comp.lang.c++