SortableIntToFloat() public static méthode

Converts a sortable int back to a float.
public static SortableIntToFloat ( int val ) : float
val int
Résultat float
Exemple #1
0
        public virtual float ParseFloat(System.String val)
        {
            int shift = val[0] - NumericUtils.SHIFT_START_INT;

            if (shift > 0 && shift <= 31)
            {
                throw new FieldCacheImpl.StopFillCacheException();
            }
            return(NumericUtils.SortableIntToFloat(NumericUtils.PrefixCodedToInt(val)));
        }
Exemple #2
0
        public virtual void TestFloats()
        {
            float[] vals    = new float[] { float.NegativeInfinity, -2.3E25f, -1.0E15f, -1.0f, -1.0E-1f, -1.0E-2f, -0.0f, +0.0f, 1.0E-2f, 1.0E-1f, 1.0f, 1.0E15f, 2.3E25f, float.PositiveInfinity, float.NaN };
            int[]   intVals = new int[vals.Length];

            // check forward and back conversion
            for (int i = 0; i < vals.Length; i++)
            {
                intVals[i] = NumericUtils.FloatToSortableInt(vals[i]);
                Assert.IsTrue(vals[i].CompareTo(NumericUtils.SortableIntToFloat(intVals[i])) == 0, "forward and back conversion should generate same double");
            }

            // check sort order (prefixVals should be ascending)
            for (int i = 1; i < intVals.Length; i++)
            {
                Assert.IsTrue(intVals[i - 1] < intVals[i], "check sort order");
            }
        }