ref: 534e73b59d204c56a3b3cfa358909b3f7f89ad66
dir: /llt.c/
#include "llt.h" #include "random.h" double D_PNAN, D_NNAN, D_PINF, D_NINF; float F_PNAN, F_NNAN, F_PINF, F_NINF; void llt_init(void) { D_PNAN = strtod("+NaN", nil); D_NNAN = strtod("-NaN", nil); D_PINF = strtod("+Inf", nil); D_NINF = strtod("-Inf", nil); *(uint32_t*)&F_PNAN = 0x7fc00000; *(uint32_t*)&F_NNAN = 0xffc00000; *(uint32_t*)&F_PINF = 0x7f800000; *(uint32_t*)&F_NINF = 0xff800000; randomize(); ios_init_stdstreams(); } char * uint2str(char *dest, size_t len, uint64_t num, uint32_t base) { int i = len-1; uint64_t b = (uint64_t)base; char ch; dest[i--] = '\0'; while(i >= 0){ ch = (char)(num % b); if(ch < 10) ch += '0'; else ch = ch-10+'a'; dest[i--] = ch; num /= b; if(num == 0) break; } return &dest[i+1]; } int isdigit_base(char c, int base) { if(base < 11) return c >= '0' && c < '0'+base; return (c >= '0' && c <= '9') || (c >= 'a' && c < 'a'+base-10) || (c >= 'A' && c < 'A'+base-10); }