if you reeally need to check for underflow, and you need to use the libc function for some reason
Indeed: in many cases the standard lib is best avoided altogether (this was about errors, but there are locales too. And if you want your locale to influence how you interpret the comma and the point, you probably want to be explicit about it).
If proper floating point parsing isn’t too important, perhaps just do the most expedient thing that’s barely good enough. If it does matter though, you should probably roll your own. With any luck, there are good implementations out there you can steal from.
It’s even more fun when you have to support multiple floating point formats. I wrote an 8-bit assembler that supports IEEE-754 (because there’s a ROM that implements it for the 8-bit CPU), and the Microsoft Binary Format (because the BASIC that comes with the computer is from Microsoft, and it came out prior to IEEE-754 was standardized). Fun times.
Indeed: in many cases the standard lib is best avoided altogether (this was about errors, but there are locales too. And if you want your locale to influence how you interpret the comma and the point, you probably want to be explicit about it).
If proper floating point parsing isn’t too important, perhaps just do the most expedient thing that’s barely good enough. If it does matter though, you should probably roll your own. With any luck, there are good implementations out there you can steal from.
score 1 · canonical
It’s even more fun when you have to support multiple floating point formats. I wrote an 8-bit assembler that supports IEEE-754 (because there’s a ROM that implements it for the 8-bit CPU), and the Microsoft Binary Format (because the BASIC that comes with the computer is from Microsoft, and it came out prior to IEEE-754 was standardized). Fun times.
score 1 · canonical