如何把for循环里的chirp存到一个数组里呢?转化为16位二进制如何写入文件
public Form1()
{
InitializeComponent();
Stopwatch sw = new Stopwatch();
sw.Start();
string filePath = System.AppDomain.CurrentDomain.
SetupInformation.ApplicationBase + @"cp.txt";//设置路径将文件保存在目标文件下
double t0 = 0, f0 = 100000d;
//double beta = (f1 - f0) / t1;
double beta = 900000d/4.194304d;
double chirp = 0;
int c;
int[] bases = { 2, 8, 10, 16 };
int[] numbers = { Int32.MinValue, -19327543, -13621, -18, 12,
19142, Int32.MaxValue };
using(FileStream fs = File.Create(filePath))
{
for (int i=0; i<=167772160; i++)
{
chirp = Math.Cos(Math.PI * (2 * f0 + beta * t0) * t0);
t0 += 0.000000025;
chirp = Math.Round(chirp * 2046);
chirp = chirp*2 + 2046;
c = (int)chirp;
foreach (int baseValue in bases)
{
Console.WriteLine("Base {0} conversion:", baseValue);
foreach (int number in numbers)
{
Console.WriteLine(" {0,-15} --> 0x{1}",
number, Convert.ToString(number, baseValue));
}
}
}
sw.Stop();
MessageBox.Show("耗时为: " + sw.ElapsedMilliseconds.ToString() + " ms");
}
}