public SpectrumChar CloneForNumber(SpectrumNumber number) { return new SpectrumChar() { Code = this.Code, Type = this.Type, Text = this.Text, Number = number }; }
public static void CheckSpectrumNumbers() { // Examples : // Number Five byte form // 0.375 7F 40 00 00 00 // PI 82 49 0F DA A2 // –1.5E20 C4 82 1A B0 D4 // 1000 00 00 E8 03 00 // –1000 00 FF 18 FC 00 byte[] fivebytes1 = new byte[] { 0x7F, 0x40, 0x00, 0x00, 0x00 }; byte[] fivebytes2 = new byte[] { 0x82, 0x49, 0x0F, 0xDA, 0xA2 }; byte[] fivebytes3 = new byte[] { 0xC4, 0x82, 0x1A, 0xB0, 0xD4 }; byte[] fivebytes4 = new byte[] { 0x00, 0x00, 0xE8, 0x03, 0x00 }; byte[] fivebytes5 = new byte[] { 0x00, 0xFF, 0x18, 0xFC, 0x00 }; SpectrumNumber numberFromBytes1 = new SpectrumNumber(fivebytes1); SpectrumNumber numberFromBytes2 = new SpectrumNumber(fivebytes2); SpectrumNumber numberFromBytes3 = new SpectrumNumber(fivebytes3); SpectrumNumber numberFromBytes4 = new SpectrumNumber(fivebytes4); SpectrumNumber numberFromBytes5 = new SpectrumNumber(fivebytes5); SpectrumNumber bytesFromNumber1 = new SpectrumNumber(0.375); SpectrumNumber bytesFromNumber2 = new SpectrumNumber(3.14159265346825); SpectrumNumber bytesFromNumber3 = new SpectrumNumber(-1.5E20); SpectrumNumber bytesFromNumber4 = new SpectrumNumber(1000); SpectrumNumber bytesFromNumber5 = new SpectrumNumber(-1000); SpectrumNumber bytesFromText1 = new SpectrumNumber("0.375"); SpectrumNumber bytesFromText2 = new SpectrumNumber("3.14159265346825"); SpectrumNumber bytesFromText3 = new SpectrumNumber("-1.5E20"); SpectrumNumber bytesFromText4 = new SpectrumNumber("1000"); SpectrumNumber bytesFromText5 = new SpectrumNumber("-1000"); }
private static SpectrumNumber ReadSpectrumNumber(Stream binaryMemoryStream, ref int bytesCounter) { byte[] numBytes = new byte[5]; for (int j = 0; j < 5; j++) { numBytes[j] = (byte)binaryMemoryStream.ReadByte(); bytesCounter++; } SpectrumNumber spectrumNumber = new SpectrumNumber(numBytes); return spectrumNumber; }