Humanity

Edit the world by your favorite way

2009-11-11から1日間の記事一覧

double2string

C

適当だなぁ。 あとstring2double()もそうだけどstring2double([from], [to])な引数なのがちょっと紛らわしいかも。 1.00000 -> 1とかせずに最初からsnprintf()使わず自前で変換すればうんたらかんたら。 bool digit2token(double digit, char *str, size_t m…

string2double

C

使わなくなったので晒し。 元はman strtolからパクったんだったと思う。 bool string2double(char *str, double *digit) { char *end_ptr; errno = 0; *digit = strtod(str, &end_ptr); if (errno == ERANGE || (errno != 0 && *digit == 0)) { return false…