Re: [Dev-C++] Rounding off Floating Point numbers
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Eric <eri...@wo...> - 2008-04-08 14:30:50
|
Ummmm did you want the answer for c or c++
here it is for C, try this out
=================================
#include <cstdlib>
#include <iostream>
float x=1;
using namespace std;
int main(int argc, char *argv[])
{
cout << "1/3 =" << x/3 << "\n";
printf("1/3 = %.9f \n", x/3);
system("PAUSE");
return EXIT_SUCCESS;
}
==============================
printf("1/3 = %.9f \n", x/3);
the %.9f will give the answer to 9 decimal places
>From Eric
----- Original Message -----
From: Deepesh Kapadia
To: dev...@li...
Sent: Tuesday, 08 April, 2008 9:28 PM
Subject: [Dev-C++] Rounding off Floating Point numbers
Hello,
I would like to know if i have a value held in a float variable, how would I
fix the value to one decimal place???
I'm using Dev C++ Ver. 4 ..I know that to fix a floating point number I
first have to include the header <iomanip>, which i have already done....
I dont know wat to do next..Pliz Help...
thanks.
--
---Deepesh Kapadia---
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javao
ne
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
No virus found in this incoming message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.9/1364 - Release Date: 07-Apr-08
6:38 PM
|