Skip to content

Instantly share code, notes, and snippets.

@jerome-pouiller
Last active August 19, 2020 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerome-pouiller/549793880c46f93960716ee01b4a4888 to your computer and use it in GitHub Desktop.
Save jerome-pouiller/549793880c46f93960716ee01b4a4888 to your computer and use it in GitHub Desktop.
/*
* Licence: GPL
* Created: 2020-08-18 17:36:11+02:00
* Main authors:
* - Jérôme Pouiller <jerome.pouiller@silabs.com>
*/
#include <stdio.h>
int main(int argc, char *argv[]) {
int X = 10000;
int a = 300020;
int b = 200000;
int res0, res1, res2, res3, res4;
float res_float;
res_float = (float)X * (float)a / (float)b;
res0 = X * (a / b) + (a % b) * (X / b) + (a % b) * (X % b) / b;
res1 = (X * a) / b;
res2 = (X / b) * a;
res3 = X * (a / b);
if (b / a)
res4 = X / (b / a);
else
res4 = -1;
printf("%d %d %d %d %d %d\n", (int)res_float, res0, res1, res2, res3, res4);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment