
1 文本格式
using System;
namespace Legalsoft.Truffer
 {
     /// <summary>
     /// Implements Knuth's subtractive generator using only floating operations. See
     /// text for cautions.
     /// </summary>
     public class Ranfib
     {
         private double[] dtab { get; set; } = new double[55];
         private double dd { get; set; }
         private int inext { get; set; }
         private int inextp { get; set; }
        public Ranfib(ulong j)
         {
             this.inext = 0;
             this.inextp = 31;
             Ranq1 init = new Ranq1(j);
             for (int k = 0; k < 55; k++)
             {
                 dtab[k] = init.doub();
             }
         }
        public double doub()
         {
             if (++inext == 55)
             {
                 inext = 0;
             }
             if (++inextp == 55)
             {
                 inextp = 0;
             }
             dd = dtab[inext] - dtab[inextp];
             if (dd < 0)
             {
                 dd += 1.0;
             }
             return (dtab[inext] = dd);
         }
        /// <summary>
         /// Returns random 32-bit integer. 
         /// Recommended only for testing purposes.
         /// </summary>
         /// <returns></returns>
         public uint int32()
         {
             return (uint)(doub() * 4294967295.0);
         }
     }
 }
  
2 代码格式
using System;
namespace Legalsoft.Truffer
{
    /// <summary>
    /// Implements Knuth's subtractive generator using only floating operations. See
    /// text for cautions.
    /// </summary>
    public class Ranfib
    {
        private double[] dtab { get; set; } = new double[55];
        private double dd { get; set; }
        private int inext { get; set; }
        private int inextp { get; set; }
        public Ranfib(ulong j)
        {
            this.inext = 0;
            this.inextp = 31;
            Ranq1 init = new Ranq1(j);
            for (int k = 0; k < 55; k++)
            {
                dtab[k] = init.doub();
            }
        }
        public double doub()
        {
            if (++inext == 55)
            {
                inext = 0;
            }
            if (++inextp == 55)
            {
                inextp = 0;
            }
            dd = dtab[inext] - dtab[inextp];
            if (dd < 0)
            {
                dd += 1.0;
            }
            return (dtab[inext] = dd);
        }
        /// <summary>
        /// Returns random 32-bit integer. 
        /// Recommended only for testing purposes.
        /// </summary>
        /// <returns></returns>
        public uint int32()
        {
            return (uint)(doub() * 4294967295.0);
        }
    }
}
 
                


















