src/opal.js
function cutNumber() {
        if (isFloat()) {
          var numerator = parseFloat(cutFloat());

          if (str[0] === '/') {
            // rational real part
            str = str.slice(1);

            if (isFloat()) {
              var denominator = parseFloat(cutFloat());
              return self.$Rational(numerator, denominator);
            } else {
              // reverting '/'
              str = '/' + str;
              return numerator;
            }
          } else {
            // float real part, no denominator
            return numerator;
          }
        } else {
          return null;
        }
      }
function cutNumber() {
        if (isFloat()) {
          var numerator = parseFloat(cutFloat());

          if (str[0] === '/') {
            // rational real part
            str = str.slice(1);

            if (isFloat()) {
              var denominator = parseFloat(cutFloat());
              return self.$Rational(numerator, denominator);
            } else {
              // reverting '/'
              str = '/' + str;
              return numerator;
            }
          } else {
            // float real part, no denominator
            return numerator;
          }
        } else {
          return null;
        }
      }
function cutNumber ( ) { if ( isFloat ( ) ) { var numerator = parseFloat ( cutFloat ( ) ) ; if ( str [ 0 ] === '/' ) { // rational real part str = str . slice ( 1 ) ; if ( isFloat ( ) ) { var denominator = parseFloat ( cutFloat ( ) ) ; return self . $Rational ( numerator , denominator ) ; } else { // reverting '/' str = '/' + str ; return numerator ; } } else { // float real part, no denominator return numerator ; } } else { return null ; } }
handles both floats and rationals
handles both floats and rationals