All pastes #1385641 Raw Edit

IM_BORED

public c v1 · immutable
#1385641 ·published 2009-04-08 03:48 UTC
rendered paste body
#ifdef IM_FUCKING_BOREDstatic const uint32_t table[] = {/* big-endian */0x01ff0aff,0x64ff03e8,0xff2710ff,0x0186a0ff,0x0f4240ff,0x989680ff,0x05f5e100,0xff3b9aca,0x00ff0254,0x0be400ff,0x174876e8,0x00ffe8d4,0xa51000ff,0x09184e72,0xa000ff5a,0xf3107a40,0x00ff038d,0x7ea4c680,0x00ff2386,0xf26fc100,0x00ff0163,0x45785d8a,0x0000ff0d,0xe0b6b3a7,0x640000ff,/* little-endian */0xff0aff01,0xe803ff64,0xff1027ff,0xffa08601,0xff40420f,0xff809698,0x00e1f505,0xca9a3bff,0x5402ff00,0xff00e40b,0xe8764817,0xd4e8ff00,0xff0010a5,0x724e1809,0x5aff00a0,0x407a10f3,0x8d03ff00,0x80c6a47e,0x8623ff00,0x00c16ff2,0x6301ff00,0x8a5d7845,0x0dff0000,0xa7b3b6e0,0xff000064};static int endian() {uint32_t e = 1;return (*((unsigned char *) (&e)));}int base10len_i(int x) { 	const unsigned char *tabp = (unsigned char *)(table + (endian()*25));	int read = 0, i = 0, n = x < 0 ? (x *= -1) ? 1 : 1 : x == 0 ? 1 : 0,rst=0;	unsigned buf = 0;	for(;;) {		if (*tabp == 0xff) {			i++;			rst = 1;		} else {			buf = buf << 8 | *tabp;			read++;		}		tabp++;		if (rst) {			if (x < buf) 				return n;			n++;			buf = rst = read = 0;		} else			if (read > sizeof(buf)) 				return -1;	}}#elseint base10len_i(int x) {	size_t n = x < 0 ? (x *= -1) ? 1 : 1 : x == 0 ? 1 : 0;	int u; for (u = 1; x >= u; u *= 10, ++n);		return n;	}#endif