|
From: <Mat...@bm...> - 2008-04-02 15:03:49
|
I use this function which I got from S.C Wong from code project. It will
round a double to two decimal places. You need to include math.h to use
it though.
// rounds a double variable to nPlaces decimal places
double Round(double dbVal, int nPlaces /* = 0 */)
{
const double dbShift = pow(10.0, nPlaces);
return floor(dbVal * dbShift + 0.5) / dbShift;
}
Hope that helps,
MT
________________________________
From: dev...@li...
[mailto:dev...@li...] On Behalf Of
Deepesh Kapadia
Sent: 02 April 2008 10:52
To: dev...@li...
Subject: Re: [Dev-C++] Arry dimensions
hello all,
I have a question here..
How to set a float datatype's value to 2 decimal places??
and also wat code to use to set the currency value of value set in a
float or double datatype???
Will it be the same as setting it to 2 dp, as in my first question???
please do reply,
Thanx..
==DK==
This email was sent from an email account of BMW (UK) Manufacturing Limited. BMW (UK) Manufacturing Limited is a company registered in England and Wales with company number 3950868; and has its offices at Ellesfield Avenue, Bracknell, Berkshire, RG12 8TA; registered in England and Wales. The contents of this e-mail are confidential and may be privileged and subject to internal monitoring. If you are not the addressee indicated in this message, you may not copy, forward, disclose, deliver or otherwise use it or any part of it in any form whatsoever. You should then kindly notify the sender by replying to this message and destroy it thereafter. Opinions, conclusions and other information in this message that do not relate to the official business of any BMW Group Company shall be understood as neither given nor endorsed by them.
|