public BasicPriority(PriorityType pt, double value) { this.PriorityType = pt; Percent = new FloatingPointValue { Value = value }; }
public override string ToString() { string ans; ans = "Numerical value: " + NumericValue.ToString() + Environment.NewLine + "Floating point value: " + FloatingPointValue.ToString() + Environment.NewLine + "Rational value " + RationalNumeratorValue.ToString() + "/" + RationalDenominatorValue; if (MeasurmentUnitCodeSequence != null) { ans = ans + Environment.NewLine + " Measurement units sequence --> " + Environment.NewLine + MeasurmentUnitCodeSequence.ToString(); } return(ans); }
/// <summary> /// Reads a double from an array of bytes. /// </summary> /// <param name="addr">A value index, aka address.</param> /// <returns>A double value.</returns> public double ReadDouble(int addr) { var mem = Items; var fp = new FloatingPointValue(); fp.B = (int)mem[addr++]; fp.B |= (int)mem[addr++] << 8; fp.B |= (int)mem[addr++] << 16; fp.B |= (int)mem[addr++] << 24; fp.A = (int)mem[addr++]; fp.A |= (int)mem[addr++] << 8; fp.A |= (int)mem[addr++] << 16; fp.A |= (int)mem[addr] << 24; return(fp.F); }
/// <summary> /// Writes a double value to an address. /// </summary> /// <param name="addr">A value index, aka address.</param> /// <param name="value">A value.</param> public void Write(int addr, double value) { var mem = Items; var fp = new FloatingPointValue() { F = value }; mem[addr++] = (byte)fp.B; mem[addr++] = (byte)(fp.B >> 8); mem[addr++] = (byte)(fp.B >> 16); mem[addr++] = (byte)(fp.B >> 24); mem[addr++] = (byte)(fp.A); mem[addr++] = (byte)(fp.A >> 8); mem[addr++] = (byte)(fp.A >> 16); mem[addr] = (byte)(fp.A >> 24); }
public abstract int CompareTo(FloatingPointValue other);
public void GivenICreateANewFloatingPointNumberWithDefaults() => fp = new FloatingPointValue();
public void GivenIHaveAFloatingPointNumberOf(double num) => fp = new FloatingPointValue { Value = num };