码迷,mamicode.com
首页 > 其他好文 > 详细

通过误差来控制数据精度

时间:2014-11-20 01:23:10      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   os   sp   for   数据   on   

//话不多说,直接上代码----------看注释就明白        
public static void getSmallFramPoint()
        {
            string framString ="Row,"+"Colum,"+ "framX," + "framY\r\n";
            float i = 15f;
            float j =70f ;
            float a=0;
            float b=0;
            int row = 0;
            int colum = 0;
            int lan = 0;
            int lon = 0;
            for ( i = 15f; i <= 55f; i++)
            {
                lan =Convert.ToInt32(i);
                for (j =70f; j <= 137f; j++)
                {
                    lon = Convert.ToInt32(j) ;
                    for (a = i; a <= i + 1.005f; a += 0.01f)         //0.005用来控制浮点型的误差
                    {
                        row++;
                        for(b=j;b<=j+1.005;b+=0.01f)
                        {
                            colum++;
                            framString += row.ToString() + "," + colum.ToString() + "," + b.ToString("0.00") + "," + a.ToString("0.00") + "\r\n";
                        }
                        colum = 0;
                    }
                    row = 0;
                    //输出
                    System.IO.File.WriteAllText(@"G:\RZPU\20141118fishnet\test\" + lan.ToString() + "-" + lon.ToString() + ".csv", framString);
                    framString = "Row," + "Colum," + "framX," + "framY\r\n";
                    
                }
            }
        }

通过误差来控制数据精度

标签:style   blog   io   color   os   sp   for   数据   on   

原文地址:http://www.cnblogs.com/shangguanjinwen/p/4109501.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!