title: Converting object to long
body: <p>I have the following function:</p>
  
  <pre><code>    public virtual long AsLong(object originalValue,long defaultValue)
      {
          double buffer = defaultValue;
          if (originalValue != null)
          {
              double result;
              var readValueIsconverted = double.TryParse(originalValue.ToString(), out result);
              if (readValueIsconverted)
                  buffer = result;
          }
  
          var roundedValue = Math.Round(buffer, 0);
          var convertedValue = (long) roundedValue;
          return convertedValue;
      }
  </code></pre>
  
  <p>I have used double in order to allow conversion of 14.4!
  I have the following failing test:</p>
  
  <pre><code>    [Fact]
      public void CanConvertLongMaxValue()
      {
          var cellValue = new Converter();
          const long longValue = 0x7FFFFFFFFFFFFFFF;
          var result = cellValue.AsLong(longValue, 12);
  
          Assert.Equal(longValue, result);
  
      } 
  </code></pre>
  
  <p>I have traced the code and roundedValue is positive but the convertedValue is negative. so what is the problem?</p>