Created
October 20, 2014 10:06
-
-
Save madex/5daf4a673103449240da to your computer and use it in GitHub Desktop.
division by 10 as multply an shift.
This file contains 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
// (uint64_t val) 26 till 11184819 correct, (uint32_t val) 19 bis 81920 correct | |
#define BITS 19 | |
#define MUL (((1L << BITS)/10) + 1) | |
unsigned long div10(unsigned long val) { | |
return ((unsigned long) val * MUL) >> BITS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment