Created
August 24, 2012 03:45
-
-
Save christianroman/3445224 to your computer and use it in GitHub Desktop.
Floating point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* File: main.cpp | |
* Author: christian | |
* | |
* Created on 9 de junio de 2012, 9:07 | |
*/ | |
#include <cstdlib> | |
#include <math.h> | |
#include <stdio.h> | |
using namespace std; | |
/* | |
* | |
*/ | |
int main(int argc, char** argv) { | |
double x = 1005.94309987; | |
int prec = 7; | |
double result = ceil( x * pow(10,(double)prec) - .4999999999999) / pow(10,(double)prec); | |
printf("%f", result); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment