in reply to Re^3: how to convert fractional string to decimal numbers ?
in thread how to convert fractional string to decimal numbers ?

Um, the string "2/3" no more matches the op's stated case than "-1/2" does. If you really only want to match the given case you could just test for string equality with "1/2" and return 0.5 or "undefined". Anything else is a generalization. It is a fallacy to say that one thing matches the particular case while another doesn't because it fits your first approach. And taking such assumptions and running with them is a sure way to wind up miscommunicating.

We agree that you need to generalize somehow, and errors should be explicit. But I think that you stopped with too limited a generalization, and I would have liked to see the limits of your approach stated up front.

  • Comment on Re^4: how to convert fractional string to decimal numbers ?