-
-
Save MurageKibicho/452d19b37e6d12c1486c6fc281852e76 to your computer and use it in GitHub Desktop.
FixedPoint
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
// Online C compiler to run C program online | |
#include <stdio.h> | |
#include <stdint.h> | |
typedef int64_t fixedpt; | |
#define FIXEDPT_BITS 32 | |
#define FIXEDPT_WBITS 24 | |
#define FIXEDPT_FBITS (FIXEDPT_BITS - FIXEDPT_WBITS) | |
#define FIXEDPT_ONE ((fixedpt)((fixedpt)1 << FIXEDPT_FBITS)) | |
#define fixedpt_rconst(R) ((fixedpt)((R) * FIXEDPT_ONE + ((R) >= 0 ? 0.5 : -0.5))) | |
int main() { | |
fixedpt a = fixedpt_rconst(-4545.8); | |
printf("%d\n", a); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment