title: Why don't check the range overflow when converting "Number" to "Float" or "Double" in Spring Boot framework source code
body: <p>please look at the source code snippet that is from <code>org.springframework.util.NumberUtils#convertNumberToTargetClass()</code>, the method signature is <code>+ &lt;T extends Number&gt; T convertNumberToTargetClass(number:Number, targetClass:Class&lt;?&gt;)</code></p>
  <pre><code>public static &lt;T extends Number&gt; T convertNumberToTargetClass(Number number, Class&lt;T&gt; targetClass)
              throws IllegalArgumentException {
      ... ...
      ... ...
      else if (Float.class == targetClass) {
          return (T) Float.valueOf(number.floatValue());
      }
      .... ....
      .... ....
  }
  </code></pre>
  <p>When converting <code>number</code> to <code>Float</code>, it doesn't check whether the <code>number</code> overflows the range of <code>Float</code> or not. But it does check that when converting number to <code>Byte</code>, <code>Integer</code> or <code>Short</code>, as showing below:</p>
  <pre><code>    public static &lt;T extends Number&gt; T convertNumberToTargetClass(Number number, Class&lt;T&gt; targetClass)
              throws IllegalArgumentException {
          ... ...
          ... ...
          else if (Byte.class == targetClass) {
              long value = checkedLongValue(number, targetClass);
              if (value &lt; Byte.MIN_VALUE || value &gt; Byte.MAX_VALUE) {
                  raiseOverflowException(number, targetClass);
              }
              return (T) Byte.valueOf(number.byteValue());
          }
          ... ...
          ... ...
      }
  
      private static long checkedLongValue(Number number, Class&lt;? extends Number&gt; targetClass) {
          BigInteger bigInt = null;
          if (number instanceof BigInteger) {
              bigInt = (BigInteger) number;
          }
          else if (number instanceof BigDecimal) {
              bigInt = ((BigDecimal) number).toBigInteger();
          }
          // Effectively analogous to JDK 8's BigInteger.longValueExact()
          if (bigInt != null &amp;&amp; (bigInt.compareTo(LONG_MIN) &lt; 0 || bigInt.compareTo(LONG_MAX) &gt; 0)) {
              raiseOverflowException(number, targetClass);
          }
          return number.longValue();
      }
  
      private static void raiseOverflowException(Number number, Class&lt;?&gt; targetClass) {
          throw new IllegalArgumentException(&quot;Could not convert number [&quot; + number + &quot;] of type [&quot; +
              number.getClass().getName() + &quot;] to target class [&quot; + targetClass.getName() + &quot;]: overflow&quot;);
      }
  </code></pre>
  <p>I'm really curious why!</p>