4 ms·
Tougher than it looks at first sight: * there is no length argument * localization, should it contain dots or commas? * the minus sign or a plus sign should
by MrQuincle 10y ago
Tougher than it looks at first sight:
* there is no length argument
* localization, should it contain dots or commas?
* the minus sign or a plus sign should be only at start
* there should be only a single decimal separator
* just a dot is not a number
* just a minus or plus sign is not a number
* empty string is not a number
* there should be only a single minus or plus sign
* there should be a minus OR a plus sign
* let's assume something like .0 or 0. is allowed
* let's assume 4E04 is not allowed (although it is a positive integer)
- therein 10y agoYup, those are exactly what we look for as well. And yes, you're correct at all of those assumptions. :)
- closeparen 10y agoDoes the candidate get to develop this code iteratively and test it, or is it a timed/whiteboard scenario?
- therein 10y agoThey develop the code iteratively and test it while thinking out loud.
- MrQuincle 10y agoThis is a nice example of how much work goes into a good implementation: http://www.exploringbinary.com/how-strtod-works-and-sometimes-doesnt/ http://www.exploringbinary.com/how-strtod-works-and-sometime...