The value of endp returned by strtod() was off by one. There was also a const char * vs char * assignment that I took the opportunity to fix.