Beispiel #1
0
        Pchp.Core.Convert.NumberInfo IPhpConvertible.ToNumber(out PhpNumber number)
        {
            var temp = IsValid ? Socket.Handle.ToInt64() : 0;

            number = PhpNumber.Create(temp);
            return(Pchp.Core.Convert.NumberInfo.LongInteger);
        }
Beispiel #2
0
 /// <summary>
 /// Converts the given number to int64 (if the number is whole and fits into the int64's range).
 /// </summary>
 /// <param name="number">The number.</param>
 /// <returns><c>long</c> representation of number if possible, otherwise a <c>double</c> representation.</returns>
 private static PhpNumber ConvertToLong(double number)
 {
     if ((Math.Round(number) == number) && (number <= long.MaxValue) && (number >= long.MinValue))
     {
         return(PhpNumber.Create((long)number));
     }
     return(PhpNumber.Create(number));
 }
Beispiel #3
0
 public static PhpNumber abs(long lx)
 {
     if (lx == long.MinValue)
     {
         return(PhpNumber.Create(-(double)lx));
     }
     else
     {
         return(PhpNumber.Create(Math.Abs(lx)));
     }
 }
Beispiel #4
0
 public static PhpNumber abs(long number)
 {
     if (number == long.MinValue)
     {
         return(PhpNumber.Create(-(double)number));
     }
     else
     {
         return(PhpNumber.Create(Math.Abs(number)));
     }
 }
Beispiel #5
0
 /// <summary>
 /// Returns the absolute value of <paramref name="x"/>.
 /// </summary>
 /// <param name="x">The numeric value to process.</param>
 public static PhpNumber abs(PhpNumber x)
 {
     return(x.IsLong
         ? abs(x.Long)
         : PhpNumber.Create(Math.Abs(x.Double)));
 }
Beispiel #6
0
 /// <summary>
 /// Returns the absolute value of <paramref name="number"/>.
 /// </summary>
 /// <param name="number">The numeric value to process.</param>
 public static PhpNumber abs(PhpNumber number)
 {
     return(number.IsLong
         ? abs(number.Long)
         : PhpNumber.Create(Math.Abs(number.Double)));
 }