Skip to content

Instantly share code, notes, and snippets.

@christianroman
Created August 24, 2012 03:45
Show Gist options
  • Save christianroman/3445224 to your computer and use it in GitHub Desktop.
Save christianroman/3445224 to your computer and use it in GitHub Desktop.
Floating point
/*
* 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