code: NFRule findRule(double number) {
          // if this is a fraction rule set, use findFractionRuleSetRule()
          if (isFractionRuleSet) {
              return findFractionRuleSetRule(number);
          }
  
          if (Double.isNaN(number)) {
              NFRule rule = nonNumericalRules[NAN_RULE_INDEX];
              if (rule == null) {
                  rule = owner.getDefaultNaNRule();
              }
              return rule;
          }
  
          // if the number is negative, return the negative number rule
          // (if there isn't a negative-number rule, we pretend it's a
          // positive number)
          if (number < 0) {
              if (nonNumericalRules[NEGATIVE_RULE_INDEX] != null) {
                  return nonNumericalRules[NEGATIVE_RULE_INDEX];
              } else {
                  number = -number;
              }
          }
  
          if (Double.isInfinite(number)) {
              NFRule rule = nonNumericalRules[INFINITY_RULE_INDEX];
              if (rule == null) {
                  rule = owner.getDefaultInfinityRule();
              }
              return rule;
          }
  
          // if the number isn't an integer, we use one f the fraction rules...
          if (number != Math.floor(number)) {
              if (number < 1 && nonNumericalRules[PROPER_FRACTION_RULE_INDEX] != null) {
                  // if the number is between 0 and 1, return the proper
                  // fraction rule
                  return nonNumericalRules[PROPER_FRACTION_RULE_INDEX];
              }
              else if (nonNumericalRules[IMPROPER_FRACTION_RULE_INDEX] != null) {
                  // otherwise, return the improper fraction rule
                  return nonNumericalRules[IMPROPER_FRACTION_RULE_INDEX];
              }
          }
  
          // if there's a master rule, use it to format the number
          if (nonNumericalRules[MASTER_RULE_INDEX] != null) {
              return nonNumericalRules[MASTER_RULE_INDEX];
          }
          else {
              // and if we haven't yet returned a rule, use findNormalRule()
              // to find the applicable rule
              return findNormalRule(Math.round(number));
          }
      }
docs: Selects an appropriate rule for formatting the number.
  @param number The number being formatted.
  @return The rule that should be used to format it