C#,数值计算——Ranq2的计算方法与源程序

1 文本格式

using System;

namespace Legalsoft.Truffer

{

/// <summary>

/// Backup generator if Ranq1 has too short a period and Ran is too slow.The

/// period is 8.5E37. Calling conventions same as Ran, above.

/// </summary>

public class Ranq2

{

private ulong v { get; set; }

private ulong w { get; set; }

public Ranq2(ulong j)

{

this.v = 4101842887655102017L;

this.w = 1;

v ^= j;

w = (ulong)int64();

v = (ulong)int64();

}

public ulong int64()

{

v ^= v >> 17;

v ^= v << 31;

v ^= v >> 8;

w = 4294957665U * (w & 0xffffffff) + (w >> 32);

return (ulong)(v ^ w);

}

/// <summary>

/// Return random double-precision floating value in the range 0. to 1.

/// </summary>

/// <returns></returns>

public double doub()

{

double r= 5.42101086242752217E-20 * int64();

return (r < 0.0) ? (1 + r) : r;

}

public uint int32()

{

return (uint)int64();

}

}

}

2 代码格式

cs 复制代码
using System;

namespace Legalsoft.Truffer
{
    /// <summary>
    /// Backup generator if Ranq1 has too short a period and Ran is too slow.The
    /// period is 8.5E37. Calling conventions same as Ran, above.
    /// </summary>
    public class Ranq2
    {
        private ulong v { get; set; }
        private ulong w { get; set; }

        public Ranq2(ulong j)
        {
            this.v = 4101842887655102017L;
            this.w = 1;
            v ^= j;
            w = (ulong)int64();
            v = (ulong)int64();
        }

        public ulong int64()
        {
            v ^= v >> 17;
            v ^= v << 31;
            v ^= v >> 8;
            w = 4294957665U * (w & 0xffffffff) + (w >> 32);
            return (ulong)(v ^ w);
        }

        /// <summary>
        /// Return random double-precision floating value in the range 0. to 1.
        /// </summary>
        /// <returns></returns>
        public double doub()
        {
            double r= 5.42101086242752217E-20 * int64();
            return (r < 0.0) ? (1 + r) : r;
        }

        public uint int32()
        {
            return (uint)int64();
        }
    }
}
相关推荐
AICDragon2 小时前
1.8%就够了:K3的896个MoE专家,为什么激活率这么低反而是好事?
人工智能·算法
hey_sml2 小时前
MySQL常用操作速记:从字符集到游标全解析
java·开发语言·mysql
广东程序猿小展2 小时前
《007初露锋芒》风灵月影13项修改器下载 007初露锋芒修改器使用方法
开发语言·javascript·ecmascript
VALENIAN瓦伦尼安教学设备3 小时前
ASHOOTER激光对中仪如何通过颜色确定调整是否合适
数据库·嵌入式硬件·算法
货拉拉技术3 小时前
重塑 Agent 度量衡:基于 LLM-as-a-Judge 的离线评估体系与实践
算法·设计模式
LccKyI3 小时前
C#学习day06(方法/函数及其关键字,附思维导图)
经验分享·学习·c#
车压3 小时前
从“为什么”理解注意力机制
算法
wabs6663 小时前
关于哈希表【力扣15.三数之和的思考】
数据结构·算法·leetcode·散列表·哈希表·三数之和
菜冻鱼3 小时前
Python-sklearn-特征工程
开发语言·人工智能·python·机器学习·numpy·matplotlib·sklearn
退休倒计时3 小时前
【每日一题】LeetCode 88. 合并两个有序数组 TypeScript
算法·leetcode·职场和发展·typescript