LarryBattle / Ratio.js

Rational numbers for Javascript
http://larrybattle.github.com/Ratio.js/
MIT License
113 stars 9 forks source link

Good guess but wrong. "1//2" isn't a fraction. #44

Closed LarryBattle closed 11 years ago

LarryBattle commented 11 years ago

For Ratio.js version 0.3.11, Ratio.guessType() thinks that most strings with "\" is a fraction.

Example

Ratio.guessType("1 // 2") == "fraction"
Ratio.guessType("1 /\ 2") == "fraction"
Ratio.guessType("1 //\\ 2") == "fraction"
LarryBattle commented 11 years ago

Use Ratio.prototype.isNaN() to check if the parsed input converts to a fraction.

Example:

Ratio.parse("1//2").isNaN() === true
Ratio.parse("1/2").isNaN() === false