zoukankan      html  css  js  c++  java
  • float和decimal执行效率 (只是代码 没有分析—)

    float版:

    public static void getSmallFramPoint()
            {
                string framString ="Row,"+"Colum,"+ "framX," + "framY
    ";
                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++;public static void getSmallFramPoint()
            {
                string framString ="Row,"+"Colum,"+ "framX," + "framY
    ";
                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") + "
    ";
                         }
                         colum = 0;
                        }
                        row = 0;
                        //输出
                        System.IO.File.WriteAllText(@"G:RZPU20141118fishnet	est" + lan.ToString() + "-" + lon.ToString() + ".csv", framString);
                        framString = "Row," + "Colum," + "framX," + "framY
    ";
                        
                    }
                }
            }
                            for(b=j;b<=j+1.005;b+=0.01f)
                            {
                                colum++;
                                framString += row.ToString() + "," + colum.ToString() + "," + b.ToString("0.00") + "," + a.ToString("0.00") + "
    ";
                         }
                         colum = 0;
                        }
                        row = 0;
                        //输出
                        System.IO.File.WriteAllText(@"G:RZPU20141118fishnet	est" + lan.ToString() + "-" + lon.ToString() + ".csv", framString);
                        framString = "Row," + "Colum," + "framX," + "framY
    ";
                        
                    }
                }
            }
     
    decimal版:
    public static void GetSmallFramPoint(decimal rows,decimal columns,int rowSpan,int columnSpan)
            {
                string framString = "Row," + "Colum," + "framX," + "framY
    ";
                decimal row=0;
                decimal column=0;
                decimal smallRow = 0;//遍历变量
                decimal smallColumn = 0;//遍历变量
                int lan = 0;//经纬度
                int lon = 0;//经纬度
                int rowNum=0;//行号
                int columnNum=0;//列号
                for (row = rows; row <rows + rowSpan; row++)
                {
                    lan = Convert.ToInt32(row);
                    for (column = columns; column < columns + columnSpan; column++)
                    {
                        lon = Convert.ToInt32(column);
                        for (smallRow = row; smallRow <= row + 1; smallRow += 0.01m)
                        {
                            rowNum++;
                            for (smallColumn = column; smallColumn <=column + 1; smallColumn += 0.01m)
                            {
                                columnNum++;
                                framString += rowNum.ToString() + "," + columnNum.ToString() + "," + smallColumn.ToString() + "," + smallRow.ToString()+"
    ";
                            }
                            columnNum = 0;
                        }
                        System.IO.File.WriteAllText(@"G:RZPU20141118fishnet	est" + lan.ToString() + "-" + lon.ToString() + ".csv", framString);
                        framString = "Row," + "Colum," + "framX," + "framY
    ";
                        rowNum = 0;
                        
                    }
                    column = columns;
                }
                row = 0;
            }
  • 相关阅读:
    POJ3709 K-Anonymous Sequence 斜率优化DP
    POJ3233 Matrix Power Series
    第六周 Leetcode 446. Arithmetic Slices II
    POJ1743 Musical Theme 最长重复子串 利用后缀数组
    Ural 1517. Freedom of Choice 后缀数组
    iOS跳转到另一个程序
    上传源码到github
    NSTimer用法,暂停,继续,初始化
    iOS中多线程原理与runloop介绍
    NSRunLoop 概述和原理
  • 原文地址:https://www.cnblogs.com/shangguanjinwen/p/4115970.html
Copyright © 2011-2022 走看看