谢谢大家,我得到了数字库,但我仍然有问题。 此代码以下只能生成0.000000000000000000000000000001到0.999999999999999999999999999999的所有数字 ,但我需要从0.00999999999999999999999999999999到0.09999999999999999999999999999999的所有数字。 所以我修改了它并且知道它卡在0.01上,因此它每次在循环中打印在文件中只有0.01,并且它不会变大! BENDER BENDING请帮忙!
const arr = [ { angeredoutsidecontrol: 1 }, { difficultiespileup: 2 } ];
function checkForKey(arr, key) {
// loop through array
for(let i = 0; i < arr.length; ++i) {
const value = arr[i];
// if value has the key, return the index
if (value.hasOwnProperty(key)) {
return i;
}
}
}
console.log('angeredoutsidecontrol', checkForKey(arr, 'angeredoutsidecontrol'));
console.log('difficultiespileup', checkForKey(arr, 'difficultiespileup'));
}
答案 0 :(得分:2)
如何通过在for循环中一次添加0.000000000000000000000000000001来生成每个数字,当数字等于0.999999999999999999999999999999时结束。
在每次迭代中将其转换为字符串并将其写入文件
答案 1 :(得分:-1)
警告:生成的文件是33千兆字节!文件太大,实际上无法打开。
try
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\user_pc\Desktop\test.txt"))
{
double number = 0;
do
{
number += 0.000000000000000000000000000001;
file.WriteLine(number.ToString("N30"));
} while (number <= 0.999999999999999999999999999999);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}