struct ghash { static std::tuple decode(unsigned h) { const unsigned S=0x80000000; int x=0,y=0; for(int i=0;i<16;i++) { x<<=1; y<<=1; if(h&S) x|=1; h<<=1; if(h&S) y|=1; h<<=1; } return std::make_tuple(x-32768,y-32768); } static unsigned encode(int x, int y) { return encode_(x+32768,y+32768); } public: //test static void test_code(int x,int y) { unsigned h=ghash::encode(x,y); auto t=ghash::decode(h); printf("src x=%X,y=%X hash=%X,check x=%X,y=%X\n",x,y,h,std::get<0>(t),std::get<1>(t)); } static void test() { for(int i=0;i<10;i++) { test_code((4<