code: private static Object toLong( BigDecimal value)
      {
      Object number;
          
      try
        {
        number =
          value.scale() == 0
          ? Long.valueOf( value.longValueExact())
          : null;
        }
      catch( Exception e)
        {
        number = null;
        }
          
      return number;
      }
docs: Returns the Long represented by the given value, or null if not an long value.