These could be useful, though I'm not sure where to put them, so I'll let someone who knows take care of that :P
char* strndup(const char* s, size_t n)
{
char* result;
size_t len = strlen(s);
if (n < len) {
len = n;
}
result = (char*)malloc(len + 1);
if (!result) {
return NULL;
}
result[len] = '\0';
return (char*)memcpy(result, s, len);
}
double round(double x) {
return (x >= 0.0) ? floor(x + 0.5) : ceil(x - 0.5);
}
I'm not so sure about that one (well, it doesn't handle all cases...), but it's fine for most.
Other additions that would be nice: log2, tgamma.
These could be useful, though I'm not sure where to put them, so I'll let someone who knows take care of that :P
I'm not so sure about that one (well, it doesn't handle all cases...), but it's fine for most.
Other additions that would be nice:
log2,tgamma.