当前位置: 首页>>代码示例>>C#>>正文


C# BinaryReader.ReadDouble方法代码示例

本文整理汇总了C#中BinaryReader.ReadDouble方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadDouble方法的具体用法?C# BinaryReader.ReadDouble怎么用?C# BinaryReader.ReadDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinaryReader的用法示例。


在下文中一共展示了BinaryReader.ReadDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadFile

    //Generalized file loading function (basically a copy paste of the titan portion of the code)
    //Loads the file "bodyNameEphem_saturn.dat"
    public Boolean LoadFile(string bodyName, List<DateTime> times)
    {
        string filename = "Assets/Data/"+bodyName+"Ephem_saturn.dat";
        if(File.Exists(filename)) {
            List<Vector3> posList = new List<Vector3>();
            Debug.Log("Loading Titan ephemera");
            BinaryReader binReader = new BinaryReader(File.Open(filename, FileMode.Open));
            bool finished = false;

            while(! finished) {
                try{
                    double x = binReader.ReadDouble();
                    double z = binReader.ReadDouble();
                    double y = binReader.ReadDouble();
                    posList.Add(new Vector3((float) x, (float)y, (float)z));
                } catch (Exception e) {
                    finished = true;
                }
            }

            //Match up the positions and times
            SortedList<DateTime, EphemerisData> titanData = new SortedList<DateTime, EphemerisData>();
            for(int i = 0; i < posList.Count && i < times.Count; i++) {
                titanData.Add(times[i], new EphemerisData(posList[i], times[i]));
            }

            bodies[bodyName] = titanData;
            return true;
        } else return false;
    }
开发者ID:mcclaskc,项目名称:Cassini-Spacecraft-Viewer,代码行数:32,代码来源:FileLoader.cs

示例2: Read

 /*
  * The binary layout is as follows:
  * Each 8 bytes is a double
  */
 public void Read(BinaryReader binaryReader)
 {
     if (doubleList == null)
     {
         doubleList = new List<double>();
     }
     long readerLength = binaryReader.BaseStream.Length;
     while (binaryReader.BaseStream.Position <= (readerLength - 8))
     {
         double toAdd = binaryReader.ReadDouble();
         if (!toAdd.Equals(double.NaN))
         {
             doubleList.Add(toAdd);
         }
         else
         {
             doubleList.TrimExcess();
             break;
         }
         // detect NaN and exit loop to prevent reader adding "0.0" values to the list
         /*if (doubleList[doubleList.Count - 1].Equals(double.NaN))
         {
             doubleList.RemoveAt(doubleList.Count - 1);
             doubleList.TrimExcess();
             break;
         }*/
     }
 }
开发者ID:JustinRoll,项目名称:SqlServerUtilities,代码行数:32,代码来源:Median.cs

示例3: Load_TitanData

    //------------------------------------- Titan -------------------------------------
    private bool Load_TitanData( int numTimesteps )
    {
        string filename = "Assets/Data/titanEphem_saturn.dat";
        int t_index = 0;
        double xPos, yPos, zPos;

        titanPos = new double[3 , numTimesteps];

        if ( File.Exists( filename ) )
        {
            BinaryReader binReader= new BinaryReader( File.Open( filename, FileMode.Open ) );
            for (t_index = 0; t_index < numTimesteps; t_index++)
            {
                xPos = binReader.ReadDouble();
                //Debug.Log( xPos );
                yPos = binReader.ReadDouble();
                //Debug.Log( yPos );
                zPos = binReader.ReadDouble();
                //Debug.Log( zPos );
                titanPos[ 0, t_index ] = xPos/10;
                titanPos[ 1, t_index ] = yPos/10;
                titanPos[ 2, t_index ] = zPos/10;
            } // end for
            binReader.Close();
            return true;
        }// end if
        else
        {
            Debug.Log( "Could not load Titan Ephem Data" );
            return false;
        }// end else
    }
开发者ID:mcclaskc,项目名称:Cassini-Spacecraft-Viewer,代码行数:33,代码来源:moveCassini.cs

示例4: ReadProgress

	public void ReadProgress(BinaryReader br) {
		int type = (int)br.ReadByte();
		switch (type) {
			case 1: {
				progress = br.ReadDouble();
				double d = br.ReadDouble();
				if (progressMax == null) progressMax = d;
			} break;
			case 2: {
				progress = br.ReadInt32();
				int i = br.ReadInt32();
				if (progressMax == null) progressMax = i;
			} break;
			default: break;
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:16,代码来源:Achievement.cs

示例5: Read

 public void Read(BinaryReader r)
 {
     int size = r.ReadInt32();
     _list = new List<double>();
     for (int i = 0; i < size; i++)
     {
         _list.Add(r.ReadDouble());
     }
 }
开发者ID:ben-thul,项目名称:SQLCLR,代码行数:9,代码来源:Median.cs

示例6: Read

 public void Read(BinaryReader r)
 {
     int count = r.ReadInt32();
     _list = new List<double>();
     for (int i = 0; i < count; i++)
     {
         double value = r.ReadDouble();
         _list.Add(value);
     }
 }
开发者ID:ben-thul,项目名称:SQLCLR,代码行数:10,代码来源:NaiveSum.cs

示例7: ReadBinaryFileFromDisk

		public void ReadBinaryFileFromDisk (string MapName)
		{
				string FilePath = Application.persistentDataPath + "/Saved Games/" + MapName;
				string FileName = FilePath + "/" + MapName + ".map";

				if (System.IO.File.Exists (FileName)) {
						FileMode mode = FileMode.Open;
						using (BinaryReader reader = new BinaryReader(File.Open(FileName, mode))) {
								try {
										// Reset the position in the stream to zero.
										reader.BaseStream.Seek (0, SeekOrigin.Begin);
										ReadSeed = reader.ReadInt32 ();
										ReadNumberOfSites = reader.ReadInt32 ();
										ReadContinentFrequency = reader.ReadDouble ();
										ReadBiomeFrequency = reader.ReadDouble ();
										ReadOctaves = reader.ReadInt32 ();
										ReadLacunarity = reader.ReadDouble ();
										ReadPersistence = reader.ReadDouble ();

										ReadCellOverrides.Clear ();
										int counter = reader.ReadInt32 ();
							
										for (int i = 0; i < counter; i++) {
												Vector site = new Vector ();
												site [0] = reader.ReadDouble ();
												site [1] = reader.ReadDouble ();
												int biomeOverride = reader.ReadInt32 ();
												ReadCellOverrides.Add (site, biomeOverride);
										}

								} catch (EndOfStreamException e) {
										//Debug.Log(e.GetType().Name + " caught and ignored. Using default values.");
								} finally {
										reader.Close ();
								}
						}
				}
		}
开发者ID:kristafervale,项目名称:MapEditor,代码行数:38,代码来源:map_f.cs

示例8: Main

 public static void Main(string [] args)
 {
     BinaryWriter output = new BinaryWriter
                (new FileStream(args[0],FileMode.Create));
     for (int i = 0; i < 10; i++)
       output.Write(i);
     for (double d = 0.0; d < 10.0; d++)
       output.Write(d);
     output.Close();
     BinaryReader input = new BinaryReader
                  (new FileStream(args[0],FileMode.Open));
     for (int i = 0; i < 10; i++)
       Console.Write("{0} ", input.ReadInt32());
     for (int i = 0; i < 10; i++)
       Console.Write("{0:F1} ", input.ReadDouble());
     input.Close();
 }
开发者ID:JnS-Software-LLC,项目名称:CSC153,代码行数:17,代码来源:Binary.cs

示例9: load

    public void load(BinaryReader buf)
    {
        m_fstep = (float)buf.ReadDouble();

        if(_objectToRotateUV.Count == 0)
        {
            Transform[] allChildren = GetComponentsInChildren<Transform>();
            foreach (Transform child in allChildren)
            {
                if(child.name.Contains(_nameObjectToRotateUV))
                {
                    _objectToRotateUV.Add(child);
                    child.GetComponent<Renderer>().material.SetFloat("_Rotation", Mathf.PI * m_fstep);
                }
            }
        }
    }
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:17,代码来源:Function_rotateUV.cs

示例10: Main

 public static void Main(string[] args)
 {
     if (args.Length != 4) {
       Console.Error.WriteLine("Usage: SHS.PageRank <leader> <store> <d> <iters>");
     } else {
       var sw = Stopwatch.StartNew();
       var store = new Service(args[0]).OpenStore(Guid.Parse(args[1]));
       double d = double.Parse(args[2]);
       int numIters = int.Parse(args[3]);
       long n = store.NumUrls();
       using (var wr = new BinaryWriter(new BufferedStream(new FileStream("pr-scores-" + 0 + ".bin", FileMode.Create, FileAccess.Write)))) {
     for (long i = 0; i < n; i++) wr.Write(1.0 / n);
       }
       var scores = store.AllocateUidState<double>();
       var uidBatch = new Batch<long>(50000);
       for (int k = 0; k < numIters; k++) {
     scores.SetAll(x => d / n);
     using (var rd = new BinaryReader(new BufferedStream(new FileStream("pr-scores-" + k + ".bin", FileMode.Open, FileAccess.Read)))) {
       foreach (long u in store.Uids()) {
         uidBatch.Add(u);
         if (uidBatch.Full || store.IsLastUid(u)) {
           var linkBatch = store.BatchedGetLinks(uidBatch, Dir.Fwd);
           var uniqLinks = new UidMap(linkBatch);
           var scoreArr = scores.GetMany(uniqLinks);
           foreach (var links in linkBatch) {
             double f = (1.0 - d) * rd.ReadDouble() / links.Length;
             foreach (var link in links) {
               scoreArr[uniqLinks[link]] += f;
             }
           }
           scores.SetMany(uniqLinks, scoreArr);
           uidBatch.Reset();
         }
       }
     }
     using (var wr = new BinaryWriter(new BufferedStream(new FileStream("pr-scores-" + (k + 1) + ".bin", FileMode.Create, FileAccess.Write)))) {
       foreach (var us in scores.GetAll()) wr.Write(us.val);
     }
     File.Delete("pr-scores-" + k + ".bin");
     Console.WriteLine("Iteration {0} complete", k);
       }
       Console.WriteLine("Done. {0} iterations took {1} seconds.", numIters, 0.001 * sw.ElapsedMilliseconds);
     }
 }
开发者ID:pszmyd,项目名称:SHS,代码行数:44,代码来源:PageRank.cs

示例11: BinFileIO

    public void BinFileIO(string path)
    {
        try
        {
            if (File.Exists(path))
                File.Delete(path);

            var fs0 = new FileStream(path, FileMode.Create, FileAccess.ReadWrite);
            using (var bw = new BinaryWriter(fs0))
            {
                int    one    = 1;
                double dl_one = 0.01;
                string res    = "leech";

                // REMARK
                // the first byte of string is its "length"
                //
                // format: length, utf8

                bw.Write(one);
                bw.Write(dl_one);
                bw.Write(res);
            }

            using (var br = new BinaryReader(fs1))
            {
                var one    = br.ReadInt32();
                var bl_one = br.ReadDouble();
                var str    = br.ReadString();

                Console.WriteLine("{0}, {1}, {2}",
                        one.ToString(), bl_one.ToString(), str);
            }
        }
        catch(Exception e)
        {
            Console.WriteLine("The process failed: {0}", e.ToString());
        }
    }
开发者ID:yielding,项目名称:code,代码行数:39,代码来源:file_io.cs

示例12: Load_CassiniData

    private bool Load_CassiniData( int numTimesteps )
    {
        string filename = "Assets/Data/cassiniEphem_saturn.dat";
        int t_index = 0;
        double xPos, yPos, zPos, delX, delY, delZ;

        cassiniPos = new double[3,numTimesteps];
        cassiniVel = new double[3,numTimesteps];

        if ( File.Exists( filename ) )
        {
            BinaryReader binReader= new BinaryReader( File.Open( filename, FileMode.Open ) );
            for (t_index = 0; t_index < numTimesteps; t_index++)
            {
                xPos = binReader.ReadDouble();
                //Debug.Log( xPos );
                yPos = binReader.ReadDouble();
                //Debug.Log( yPos );
                zPos = binReader.ReadDouble();
                //Debug.Log( zPos );
                delX = binReader.ReadDouble();
                //Debug.Log( delX );
                delY = binReader.ReadDouble();
                //Debug.Log( delY );
                delZ = binReader.ReadDouble();
                //Debug.Log( delZ );
                cassiniPos[ 0, t_index ] = xPos/10;
                cassiniPos[ 1, t_index ] = yPos/10;
                cassiniPos[ 2, t_index ] = zPos/10;
                cassiniVel[ 0, t_index ] = delX;
                cassiniVel[ 1, t_index ] = delY;
                cassiniVel[ 2, t_index ] = delZ;
            } // end for
            binReader.Close();
            return true;
        }// end if
        else
        {
            Debug.Log( "Could not load Cassini Ephem Data" );
            return false;
        }// end else
    }
开发者ID:mcclaskc,项目名称:Cassini-Spacecraft-Viewer,代码行数:42,代码来源:moveCassini.cs

示例13: Load_CassiniData

    //------------------------------------- Cassini -------------------------------------
    private bool Load_CassiniData( int numTimesteps )
    {
        int t_index = 0;
        double xPos, yPos, zPos, delX, delY, delZ;

        if ( cassiniEphemData )
        {
            BinaryReader binReader= new BinaryReader( new MemoryStream(cassiniEphemData.bytes) );

            cassiniVel = new double[3, numTimesteps];
            cassiniPos = new double[3, numTimesteps];

            for (t_index = 0; t_index < numTimesteps; t_index++)
            {
                xPos = binReader.ReadDouble();
                //Debug.Log( xPos );
                yPos = binReader.ReadDouble();
                //Debug.Log( yPos );
                zPos = binReader.ReadDouble();
                //Debug.Log( zPos );
                delX = binReader.ReadDouble();
                //Debug.Log( xPos );
                delY = binReader.ReadDouble();
                //Debug.Log( yPos );
                delZ = binReader.ReadDouble();
                //Debug.Log( zPos );
                cassiniPos[ 0, t_index ] = xPos;
                cassiniPos[ 1, t_index ] = yPos;
                cassiniPos[ 2, t_index ] = zPos;
                cassiniVel[ 0, t_index ] = delX;
                cassiniVel[ 1, t_index ] = delY;
                cassiniVel[ 2, t_index ] = delZ;
            } // end for
            binReader.Close();
            return true;
        }// end if
        else
        {
            Debug.Log( "Could not load Cassini Ephem Data" );
            return false;
        }// end else
    }
开发者ID:mcclaskc,项目名称:Cassini-Spacecraft-Viewer,代码行数:43,代码来源:ImportData.cs

示例14: ReadData

 public static void ReadData(Stream s) 
 {
     int				offset		= 5;
     byte[]			bytes		= new byte[256+offset];
     int				numBytes	= s.Read(bytes,offset,256);
     int				ret;
     int				read;
     BinaryReader	br;
     if(numBytes!=256)
         throw new Exception("When reading at an offset, expected 256 bytes back!  Got: "
             +numBytes+"  s.Position: "+s.Position+"  s.Length: "+s.Length);
     for(int i=0;i<256;i++)
         if (bytes[i+offset] != i)
             throw new Exception("Error at pos: "+(i+offset)+"  expected: "
                 +i+"  got: "+bytes[i+offset]);
     //	Test ReadByte methods
     read=s.ReadByte( );
     if(read!=0)
         throw new Exception("After calling ReadByte once, expected 0, but got: "+read);
     read=s.ReadByte( );
     if(read!=65)
         throw new Exception("After calling ReadByte twice, expected 65, but got: "+read);
     read=s.ReadByte( );
     if(read!=255)
         throw new Exception("After calling ReadByte thrice, expected 255, but got: "+read);
     br = new BinaryReader(s);
     for(int i=0;i<1000;i++) 
     {
         ret=br.ReadInt32( );
         if(ret!=i)
             Error("ReadInt32 failed, i="+i+"  read: "+ret);
     }
     if(br.ReadBoolean( ))
         throw new Exception("First call ReadBoolean( ) should have returned false!");
     if(!br.ReadBoolean( ))
         throw new Exception("Second call ReadBoolean( ) should have returned true!");
     for(char ch='A';ch<='Z';ch++)
         if(br.ReadChar( )!=ch)
             Error("ReadChar failed, ch="+ch);
     for(short i=-32000;i<=32000;i+=1000)
         if(br.ReadInt16( )!=i)
             Error("ReadInt16 failed, i="+i);
     for(int i=-2000000000;i<=2000000000;i+=100000000)
         if(br.ReadInt32( )!=i)
             Error("ReadInt32 failed, i="+i);
     if(br.ReadInt64( )!=0x0123456789ABCDE7L)
         Error("ReadInt64 forwards failed");
     if(br.ReadInt64( )!=0x7EDCBA9876543210L)
         Error("ReadInt64 backwards failed");
     if(!br.ReadString( ).Equals("Hello world"))
         Error("Read string failed");
     if(br.ReadDouble( )!=Math.PI)
         Error("ReadDouble for PI failed");
     if(br.ReadSingle( )!=(float)(-2.0*Math.PI))
         Error("ReadSingle for -2PI failed");
     s=br.BaseStream;
 }
开发者ID:ArildF,项目名称:masters,代码行数:57,代码来源:cs_iotest.cs

示例15: StreamTest

        public static async Task StreamTest(Stream stream, Boolean fSuppress)
        {

            string strValue;
            int iValue;

            //[] We will first use the stream's 2 writing methods
            int iLength = 1 << 10;
            stream.Seek(0, SeekOrigin.Begin);

            for (int i = 0; i < iLength; i++)
                stream.WriteByte((byte)i);

            byte[] btArr = new byte[iLength];
            for (int i = 0; i < iLength; i++)
                btArr[i] = (byte)i;
            stream.Write(btArr, 0, iLength);

            //we will write many things here using a binary writer
            BinaryWriter bw1 = new BinaryWriter(stream);
            bw1.Write(false);
            bw1.Write(true);

            for (int i = 0; i < 10; i++)
            {
                bw1.Write((byte)i);
                bw1.Write((sbyte)i);
                bw1.Write((short)i);
                bw1.Write((char)i);
                bw1.Write((UInt16)i);
                bw1.Write(i);
                bw1.Write((uint)i);
                bw1.Write((Int64)i);
                bw1.Write((ulong)i);
                bw1.Write((float)i);
                bw1.Write((double)i);
            }

            //Some strings, chars and Bytes
            char[] chArr = new char[iLength];
            for (int i = 0; i < iLength; i++)
                chArr[i] = (char)i;

            bw1.Write(chArr);
            bw1.Write(chArr, 512, 512);

            bw1.Write(new string(chArr));
            bw1.Write(new string(chArr));

            //[] we will now read
            stream.Seek(0, SeekOrigin.Begin);
            for (int i = 0; i < iLength; i++)
            {
                Assert.Equal(i % 256, stream.ReadByte());
            }


            btArr = new byte[iLength];
            stream.Read(btArr, 0, iLength);
            for (int i = 0; i < iLength; i++)
            {
                Assert.Equal((byte)i, btArr[i]);
            }

            //Now, for the binary reader
            BinaryReader br1 = new BinaryReader(stream);

            Assert.False(br1.ReadBoolean());
            Assert.True(br1.ReadBoolean());

            for (int i = 0; i < 10; i++)
            {
                Assert.Equal( (byte)i, br1.ReadByte());
                Assert.Equal((sbyte)i, br1.ReadSByte());
                Assert.Equal((short)i, br1.ReadInt16());
                Assert.Equal((char)i, br1.ReadChar());
                Assert.Equal((UInt16)i, br1.ReadUInt16());
                Assert.Equal(i, br1.ReadInt32());
                Assert.Equal((uint)i, br1.ReadUInt32());
                Assert.Equal((Int64)i, br1.ReadInt64());
                Assert.Equal((ulong)i, br1.ReadUInt64());
                Assert.Equal((float)i, br1.ReadSingle());
                Assert.Equal((double)i, br1.ReadDouble());
            }

            chArr = br1.ReadChars(iLength);
            for (int i = 0; i < iLength; i++)
            {
                Assert.Equal((char)i, chArr[i]);
            }

            chArr = new char[512];
            chArr = br1.ReadChars(iLength / 2);
            for (int i = 0; i < iLength / 2; i++)
            {
                Assert.Equal((char)(iLength / 2 + i), chArr[i]);
            }

            chArr = new char[iLength];
            for (int i = 0; i < iLength; i++)
//.........这里部分代码省略.........
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:101,代码来源:Stream.Methods.cs


注:本文中的BinaryReader.ReadDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。