Skip to content

Instantly share code, notes, and snippets.

@begoon
Created February 10, 2011 14:00
Show Gist options
  • Save begoon/820545 to your computer and use it in GitHub Desktop.
Save begoon/820545 to your computer and use it in GitHub Desktop.
Tricky rounding of doubles
#include <stdio.h>
int main() {
double f = 1.15;
int a = f * 100.0;
int b = f * 100.0 + 0.1E-9;
printf("a = %d, b = %d\n", a, b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment