Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            new Tests();

            SoftFloat sum      = SoftFloat.Zero;
            SoftFloat pro      = (SoftFloat)1E30f;
            float     sumFloat = 0;
            const int n        = 1000000000;

            SoftFloat two    = SoftFloat.One + SoftFloat.One;
            SoftFloat factor = (SoftFloat)1f;
            var       x      = SoftFloat.Epsilon + SoftFloat.Epsilon;

            Stopwatch watch = new Stopwatch();

            watch.Start();
            for (int i = 0; i < n; i++)
            {
                //pro *= factor;
                //sum += factor;
                sumFloat *= 1f;
            }
            watch.Stop();
            Console.WriteLine(watch.Elapsed + " " + Math.Round(n / watch.Elapsed.TotalSeconds / 1000000, 2) + "M FLOPS");
            Console.WriteLine("" + pro + " " + sumFloat + " " + sum);

            /*for (int i = 0; i < n; i++)
             * {
             *      uint i1 = RandomUInt32();
             *      uint i2 = RandomUInt32();
             *
             *      SoftFloat sf1 = SoftFloat.FromIeeeRaw(i1);
             *      SoftFloat sf2 = SoftFloat.FromIeeeRaw(i2);
             *      SoftFloat sf = sf1 * sf2;
             *
             *      float f1 = (float)sf1;
             *      float f2 = (float)sf2;
             *      float f = f1 * f2;
             *      SoftFloat sfc = (SoftFloat)f;
             *
             *      long error = SoftFloat.RawDistance(sf, sfc);
             *      if (error > 1)
             *      {
             *              Console.WriteLine(sf1.ToIeeeRaw() + " + " + sf2.ToIeeeRaw() +
             *                      " is " + sf.ToIeeeRaw() +
             *                      " expecting " + sfc.ToIeeeRaw() +
             *                      " error=" + error);
             *      }
             * }*/
            Console.ReadLine();
        }
Ejemplo n.º 2
0
 public bool IsIdentical(SoftFloat f1, uint i)
 {
     return(f1.ToIeeeRaw() == i);
 }
Ejemplo n.º 3
0
 private bool IsIdentical(SoftFloat f1, float f2)
 {
     return(f1.ToIeeeRaw() == ((SoftFloat)f2).ToIeeeRaw());
 }
Ejemplo n.º 4
0
 public bool IsIdentical(SoftFloat f1, SoftFloat f2)
 {
     return(f1.ToIeeeRaw() == f2.ToIeeeRaw());
 }