public void DoubleInfoEpsilonProperties() { DoubleInfo epsilon = new DoubleInfo(Double.Epsilon); Assert.IsTrue(epsilon.IsFinite); Assert.IsFalse(epsilon.IsInfinite); Assert.IsFalse(epsilon.IsNaN); Assert.IsTrue(epsilon.IsSubnormal); Assert.IsFalse(epsilon.IsZero); Assert.IsTrue(epsilon.Value == Double.Epsilon); }
public void DoubleInfoNaNProperties() { DoubleInfo nan = new DoubleInfo(Double.NaN); Assert.IsFalse(nan.IsFinite); Assert.IsFalse(nan.IsInfinite); Assert.IsTrue(nan.IsNaN); Assert.IsFalse(nan.IsSubnormal); Assert.IsFalse(nan.IsZero); Assert.IsTrue(Double.IsNaN(nan.Value)); }
public void DoubleInfoNegativeInfinityProperties() { DoubleInfo negInf = new DoubleInfo(Double.NegativeInfinity); Assert.IsFalse(negInf.IsFinite); Assert.IsTrue(negInf.IsInfinite); Assert.IsFalse(negInf.IsNaN); Assert.IsTrue(negInf.IsNegative); Assert.IsFalse(negInf.IsSubnormal); Assert.IsFalse(negInf.IsZero); Assert.IsTrue(negInf.Value == Double.NegativeInfinity); Assert.IsTrue(negInf.Next.Value == Double.MinValue); }
public void DoubleInfoZeroProperties() { DoubleInfo zero = new DoubleInfo(0.0); Assert.IsTrue(zero.IsFinite); Assert.IsFalse(zero.IsInfinite); Assert.IsFalse(zero.IsNaN); Assert.IsFalse(zero.IsNegative); Assert.IsFalse(zero.IsSubnormal); // This is debatable. Assert.IsTrue(zero.IsZero); Assert.IsTrue(zero.Value == 0.0); Assert.IsTrue(zero.Next.Value == Double.Epsilon); Assert.IsTrue(zero.Exponent == 0); // This isn't mathematically necessary, but IEEE754 requires it. Assert.IsTrue(zero.Mantissa == 0L); }
public void DoubleInfoOneProperties() { DoubleInfo one = new DoubleInfo(1.0); Assert.IsTrue(one.IsFinite); Assert.IsFalse(one.IsInfinite); Assert.IsFalse(one.IsNaN); Assert.IsFalse(one.IsNegative); Assert.IsFalse(one.IsSubnormal); Assert.IsFalse(one.IsZero); Assert.IsTrue(one.Value == 1.0); Assert.IsTrue(one.Next.Value != 1.0); Assert.IsTrue(one.Previous.Value != 1.0); Assert.IsTrue(one.Exponent == 0); Assert.IsTrue(one.Mantissa == 1L); }
private ConstantPoolInfo[] ParseConstantPool(ref ReadOnlySpan <byte> fileData) { ushort poolCount = fileData.ReadTwoBytes(); var infos = new ConstantPoolInfo[poolCount]; for (int i = 1; i < poolCount; i++) { var tag = (ConstantPoolTag)fileData.ReadOneByte(); switch (tag) { case ConstantPoolTag.Class: infos[i] = new ClassInfo(ref fileData); break; case ConstantPoolTag.Fieldref: infos[i] = new FieldrefInfo(ref fileData); break; case ConstantPoolTag.Methodref: infos[i] = new MethodrefInfo(ref fileData); break; case ConstantPoolTag.InterfaceMethodref: infos[i] = new InterfaceMethodrefInfo(ref fileData); break; case ConstantPoolTag.String: infos[i] = new StringInfo(ref fileData); break; case ConstantPoolTag.Integer: infos[i] = new IntegerInfo(ref fileData); break; case ConstantPoolTag.Float: infos[i] = new FloatInfo(ref fileData); break; case ConstantPoolTag.Long: infos[i] = new LongInfo(ref fileData); i++; break; case ConstantPoolTag.Double: infos[i] = new DoubleInfo(ref fileData); i++; break; case ConstantPoolTag.NameAndType: infos[i] = new NameAndTypeInfo(ref fileData); break; case ConstantPoolTag.Utf8: infos[i] = new Utf8Info(ref fileData); break; case ConstantPoolTag.MethodHandle: fileData.ReadOneByte(); fileData.ReadTwoBytes(); break; case ConstantPoolTag.MethodType: fileData.ReadTwoBytes(); break; case ConstantPoolTag.InvokeDynamic: fileData.ReadFourBytes(); break; default: throw new InvalidDataException(); } } foreach (ConstantPoolInfo info in infos) { info?.Init(infos); } return(infos); }