예제 #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);
        }
예제 #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));
 }
예제 #3
0
파일: Math.cs 프로젝트: kendallb/peachpie
 public static PhpNumber abs(long number)
 {
     if (number == long.MinValue)
     {
         return(PhpNumber.Create(-(double)number));
     }
     else
     {
         return(PhpNumber.Create(Math.Abs(number)));
     }
 }
예제 #4
0
 public static PhpNumber abs(long lx)
 {
     if (lx == long.MinValue)
     {
         return(PhpNumber.Create(-(double)lx));
     }
     else
     {
         return(PhpNumber.Create(Math.Abs(lx)));
     }
 }
예제 #5
0
 public abstract Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number);
예제 #6
0
 public static ConversionCost ToDouble(PhpNumber value) => value.IsLong ? ConversionCost.ImplicitCast : ConversionCost.Pass;
예제 #7
0
파일: Math.cs 프로젝트: kendallb/peachpie
 /// <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)));
 }
예제 #8
0
 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;
 }
예제 #9
0
 public static ConversionCost ToInt64(PhpNumber value) => value.IsLong ? ConversionCost.Pass : ConversionCost.LoosingPrecision;
예제 #10
0
        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;
        }
예제 #11
0
 public static ConversionCost ToInt64(PhpNumber value) => value.IsLong ? ConversionCost.Pass : ConversionCost.LoosingPrecision;
예제 #12
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)));
 }
예제 #13
0
 public Convert.NumberInfo ToNumber(out PhpNumber number)
 {
     number = PhpNumber.Create(Count);
     return Convert.NumberInfo.IsPhpArray | Convert.NumberInfo.LongInteger;
 }
예제 #14
0
 public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) => me.WritableString.ToNumber(out number);
예제 #15
0
        //PhpBytes IPhpConvertible.ToBinaryString();

        Convert.NumberInfo IPhpConvertible.ToNumber(out PhpNumber number)
        {
            number = PhpNumber.Create(Id);
            return Convert.NumberInfo.LongInteger;
        }
예제 #16
0
 public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) => Convert.ToNumber(me.String, out number);
예제 #17
0
 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;
 }
예제 #18
0
 public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number)
 {
     number = PhpNumber.Create(me.Double);
     return Convert.NumberInfo.IsNumber | Convert.NumberInfo.Double;
 }
예제 #19
0
 public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number)
 {
     number = PhpNumber.Create(0L);
     return Convert.NumberInfo.LongInteger;
 }
예제 #20
0
 public void Echo(PhpNumber value)
 {
     if (value.IsLong)
         Echo(value.Long);
     else
         Echo(value.Double);
 }
예제 #21
0
 public Convert.NumberInfo ToNumber(out PhpNumber number) => Value.ToNumber(out number);
예제 #22
0
 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();
 }
예제 #23
0
 public override Convert.NumberInfo ToNumber(ref PhpValue me, out PhpNumber number) => me.Alias.ToNumber(out number);
예제 #24
0
파일: Math.cs 프로젝트: iolevel/peachpie
 /// <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));
 }
예제 #25
0
 /// <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);
예제 #26
0
파일: Math.cs 프로젝트: iolevel/peachpie
 /// <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);
예제 #27
0
 public static ConversionCost ToInt32(PhpNumber value) => ToInt64(value);
예제 #28
0
 public static ConversionCost ToInt32(PhpNumber value) => ToInt64(value);
예제 #29
0
 public static ConversionCost ToDouble(PhpNumber value) => value.IsLong ? ConversionCost.ImplicitCast : ConversionCost.Pass;
예제 #30
0
 public static int Compare(PhpNumber x, PhpValue y) => x.IsLong ? Compare(x.Long, y) : Compare(x.Double, y);