Beispiel #1
0
        public static int CompareTo(javaFloat self, float value)
        {
            float m_value = self.floatValue();

            if (m_value < value)
            {
                return(-1);
            }
            if (m_value > value)
            {
                return(1);
            }
            if (m_value == value)
            {
                return(0);
            }

            // At least one of the values is NaN.
            if (javaFloat.isNaN(m_value))
            {
                return(javaFloat.isNaN(value) ? 0 : -1);
            }
            else // f is NaN.
            {
                return(1);
            }
        }
Beispiel #2
0
        internal static object Unbox(object val)
        {
#if STATIC_COMPILER || FIRST_PASS || STUB_GENERATOR
            return(null);
#else
            java.lang.Byte b = val as java.lang.Byte;
            if (b != null)
            {
                return(b.byteValue());
            }
            java.lang.Boolean b1 = val as java.lang.Boolean;
            if (b1 != null)
            {
                return(b1.booleanValue());
            }
            java.lang.Short s = val as java.lang.Short;
            if (s != null)
            {
                return(s.shortValue());
            }
            java.lang.Character c = val as java.lang.Character;
            if (c != null)
            {
                return(c.charValue());
            }
            java.lang.Integer i = val as java.lang.Integer;
            if (i != null)
            {
                return(i.intValue());
            }
            java.lang.Float f = val as java.lang.Float;
            if (f != null)
            {
                return(f.floatValue());
            }
            java.lang.Long l = val as java.lang.Long;
            if (l != null)
            {
                return(l.longValue());
            }
            java.lang.Double d = val as java.lang.Double;
            if (d != null)
            {
                return(d.doubleValue());
            }
            else
            {
                throw new java.lang.IllegalArgumentException();
            }
#endif
        }
Beispiel #3
0
        public static bool Equals(javaFloat self, object obj)
        {
            float m_value = self.floatValue();

            if (!(obj is Single))
            {
                return(false);
            }
            float temp = ((Single)obj);

            if (temp == m_value)
            {
                return(true);
            }

            return(javaFloat.isNaN(temp) && javaFloat.isNaN(m_value));
        }
Beispiel #4
0
        public static int CompareTo(javaFloat self, object value)
        {
            float m_value = self.floatValue();

            if (value == null)
            {
                return(1);
            }
            if (value is Single)
            {
                float f = (float)value;
                if (m_value < f)
                {
                    return(-1);
                }
                if (m_value > f)
                {
                    return(1);
                }
                if (m_value == f)
                {
                    return(0);
                }

                // At least one of the values is NaN.
                if (javaFloat.isNaN(m_value))
                {
                    return(javaFloat.isNaN(f) ? 0 : -1);
                }
                else // f is NaN.
                {
                    return(1);
                }
            }
            throw new ArgumentException(Environment.GetResourceString("Arg_MustBeSingle"));
        }
Beispiel #5
0
        public static string ToString(javaFloat self, string format, IFormatProvider provider)
        {
            float m_value = self.floatValue();

            return(Number.FormatSingle(m_value, format, NumberFormatInfo.GetInstance(provider)));
        }
Beispiel #6
0
 public static SingleMap GetAdapter(javaFloat self)
 {
     return(new SingleMap(self.floatValue()));
 }
Beispiel #7
0
        public static string ToString(javaFloat self, string format)
        {
            float m_value = self.floatValue();

            return(Number.FormatSingle(m_value, format, NumberFormatInfo.CurrentInfo));
        }