当前位置:网站首页>Random numbers in a long range, is that right- Random number in long range, is this the way?
Random numbers in a long range, is that right- Random number in long range, is this the way?
2022-07-03 19:02:00 【Zafo】
problem :
Can somebody verify this method. Someone can verify this method .I need a long type number inside a range of two longs. I need to be in two long Within the scope of long Type number .I use the .NET Random.Next(min, max) function which return int's. I use return int Of .NET Random.Next(min, max) function .Is my reasoning correct if I simply divide the long by 2, generate the random number and finally multiply it by 2 again? If I simply long Divide 2, Generate random number , Finally, multiply by 2, Is my reasoning correct ?Or am I too enthusiastic... I understand that my random resolution will decrease but are there any other mistakes which will lead to no such a random number. Or am I too enthusiastic …… I know my random resolution will decrease , But is there any other error that will lead to the absence of such random numbers .
long min = st.MinimumTime.Ticks; //long is Signed 64-bit integerlong max = st.MaximumTime.Ticks;int minInt = (int) (min / 2); //int is Signed 64-bit integerint maxInt = (int) (max / 2); //int is Signed 64-bit integerRandom random = new Random();int randomInt = random.Next(minInt, maxInt);long randomLong = (randomInt * 2);
Solution :
Reference resources : https://stackoom.com/en/question/RuN8边栏推荐
- Introduction to SSH Remote execution command
- leetcode:11. 盛最多水的容器【双指针 + 贪心 + 去除最短板】
- Scrape crawler framework
- 【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
- [academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time
- Scrapy爬虫框架
- Webrtc[41] - Analysis of the establishment process of webrtc transmission channel
- Add control at the top of compose lazycolumn
- 【Proteus仿真】用24C04与1602LCD设计的简易加密电子密码锁
- Unity webgl optimization
猜你喜欢
Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]. StandardContext
Pan for in-depth understanding of the attention mechanism in CV
Simulation scheduling problem of SystemVerilog (1)
Nous avons fait une plateforme intelligente de règlement de détail
【光学】基于matlab介电常数计算【含Matlab源码 1926期】
Su embedded training - Day10
We have built an intelligent retail settlement platform
Record the errors reported when running fluent in the simulator
Kratos微服务框架下实现CQRS架构模式
Transformer T5 model read slowly
随机推荐
Torch learning notes (7) -- take lenet as an example for dataload operation (detailed explanation + reserve knowledge supplement)
041. (2.10) talk about manpower outsourcing
leetcode:556. Next larger element III [simulation + change as little as possible]
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
【数学建模】基于matlab船舶三自由度MMG模型【含Matlab源码 1925期】
EGO Planner代码解析bspline_optimizer部分(2)
How to disable the clear button of ie10 insert text box- How can I disable the clear button that IE10 inserts into textboxes?
FBI 警告:有人利用 AI 换脸冒充他人身份进行远程面试
The more you talk, the more your stupidity will be exposed.
Zhengda futures news: soaring oil prices may continue to push up global inflation
Analyse du Code du planificateur ego bspline Section Optimizer (1)
Okaleido, a multimedia NFT aggregation platform, is about to go online, and a new NFT era may come
Day-27 database
我眼中真正优秀的CTO长啥样
Nous avons fait une plateforme intelligente de règlement de détail
Compose LazyColumn 顶部添加控件
Boost. Asio Library
FBI warning: some people use AI to disguise themselves as others for remote interview
【光学】基于matlab介电常数计算【含Matlab源码 1926期】
SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)