Skip to content

Instantly share code, notes, and snippets.

@realmonster
Last active July 25, 2017 08:45
Show Gist options
  • Save realmonster/3abdbf5406b878e6a0f9a53abc7ed895 to your computer and use it in GitHub Desktop.
Save realmonster/3abdbf5406b878e6a0f9a53abc7ed895 to your computer and use it in GitHub Desktop.
Get remainder by 320 for old CPU
#include <cstdio>
typedef unsigned short u16;
unsigned char table[1<<10];
void prepare()
{
for (int i=0; i<(1<<10); ++i)
table[i] = ((i%5)<<5);
}
u16 rem320(u16 a)
{
return (table[a>>6]*2) | (a & 0x3F);
}
int main()
{
prepare();
for (int i=0; i<(1<<16); ++i)
{
if ((i%320) != (int)rem320(i))
{
printf("%d\n", i);
}
}
printf("end");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment