The Quad structure, which implements the Quadruple data type, is mostly self-explanatory. You can use it as you would use a built-in Double:
   Quad qd1 = 4.5;
   Quad qd2 = 5.0;
   qd1 = qd1 * qd2;


Rather than using the overloaded operators (e.g. *=, +=, -=, /=) you can use the equivalent instance methods (e.g. Multiply, Add, Subtract, Divide) which are, due to optimization limitations in .Net, substantially faster. For example:
qd1.Multiply(5); //faster than qd1 *= 5;

It is also possible to access a Quad's bits directly, via the Exponent and Significand fields. Note that the highest bit of the Significand is the sign bit (1 if negative, 0 if positive). The remainder of the bits comprise the value of the significand as 1.[remaining 63 bits]. Zero is a special value with all-zero Significand bits and an exponent of long.MinValue. There is no "negative zero" as there is for Doubles.

Finally, Quad exposes a number of useful mathematical operations, such as Quad.Log(), Quad.Abs(), Quad.Max(), Quad.Pow(), etc., replicating the functionality that the Math class provides for Doubles.

Last edited Jun 21, 2011 at 6:25 PM by jeffpasternack, version 3

Comments

No comments yet.