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); }
/// <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)); }
public static PhpNumber abs(long lx) { if (lx == long.MinValue) { return(PhpNumber.Create(-(double)lx)); } else { return(PhpNumber.Create(Math.Abs(lx))); } }
public static PhpNumber abs(long number) { if (number == long.MinValue) { return(PhpNumber.Create(-(double)number)); } else { return(PhpNumber.Create(Math.Abs(number))); } }
/// <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))); }
/// <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))); }