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 number) { if (number == long.MinValue) { return(PhpNumber.Create(-(double)number)); } else { return(PhpNumber.Create(Math.Abs(number))); } }
public static PhpNumber abs(long lx) { if (lx == long.MinValue) { return(PhpNumber.Create(-(double)lx)); } else { return(PhpNumber.Create(Math.Abs(lx))); } }
public abstract Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number);
public static ConversionCost ToDouble(PhpNumber value) => value.IsLong ? ConversionCost.ImplicitCast : ConversionCost.Pass;
/// <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))); }
public static NumberInfo ToNumber(string str, out PhpNumber number) { long l; double d; var info = StringToNumber(str, out l, out d); number = ((info & NumberInfo.Double) != 0) ? PhpNumber.Create(d) : PhpNumber.Create(l); return info; }
public static ConversionCost ToInt64(PhpNumber value) => value.IsLong ? ConversionCost.Pass : ConversionCost.LoosingPrecision;
public Convert.NumberInfo ToNumber(out PhpNumber number) { double d; long l; var info = Convert.StringToNumber(ToString(), out l, out d); number = (info & Convert.NumberInfo.Double) != 0 ? PhpNumber.Create(d) : PhpNumber.Create(l); return info; }
/// <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))); }
public Convert.NumberInfo ToNumber(out PhpNumber number) { number = PhpNumber.Create(Count); return Convert.NumberInfo.IsPhpArray | Convert.NumberInfo.LongInteger; }
public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) => me.WritableString.ToNumber(out number);
//PhpBytes IPhpConvertible.ToBinaryString(); Convert.NumberInfo IPhpConvertible.ToNumber(out PhpNumber number) { number = PhpNumber.Create(Id); return Convert.NumberInfo.LongInteger; }
public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) => Convert.ToNumber(me.String, out number);
public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) { number = PhpNumber.Create(me.Boolean ? 1L : 0L); return Convert.NumberInfo.IsNumber | Convert.NumberInfo.LongInteger; }
public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) { number = PhpNumber.Create(me.Double); return Convert.NumberInfo.IsNumber | Convert.NumberInfo.Double; }
public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) { number = PhpNumber.Create(0L); return Convert.NumberInfo.LongInteger; }
public void Echo(PhpNumber value) { if (value.IsLong) Echo(value.Long); else Echo(value.Double); }
public Convert.NumberInfo ToNumber(out PhpNumber number) => Value.ToNumber(out number);
public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) { if (me.Object is IPhpConvertible) return ((IPhpConvertible)me.Object).ToNumber(out number); throw new NotImplementedException(); }
public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) => me.Alias.ToNumber(out 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 <paramref name="base"/> raised to the power of <paramref name="exp"/>. /// </summary> public static PhpNumber pow(PhpNumber @base, PhpNumber exp) => PhpNumber.Pow(@base, exp);
public static ConversionCost ToInt32(PhpNumber value) => ToInt64(value);
public static int Compare(PhpNumber x, PhpValue y) => x.IsLong ? Compare(x.Long, y) : Compare(x.Double, y);