ref: f13f110f2d09c959fee5abe27d3cee3c7dfeddef
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); #ifdef __plan9__ *(uint32_t*)&F_PNAN = 0x7fc00000; *(uint32_t*)&F_NNAN = 0xffc00000; *(uint32_t*)&F_PINF = 0x7f800000; *(uint32_t*)&F_NINF = 0xff800000; #else F_PNAN = strtof("+NaN", nil); F_NNAN = strtof("-NaN", nil); F_PINF = strtof("+Inf", nil); F_NINF = strtof("-Inf", nil); #endif 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); }