ADC Home > Reference Library > Technical Q&As > Carbon > Human Interface Toolbox >

Using the Wide Routines in <FixMath.h>

Q There is a type defined in the <FixMath.h> header called 'wide', and there are some associated routines for doing 64-bit math. Where are these routines documented, and why aren't they available on 68K machines?

A There is no documentation available on these routines at present (there is a bug report on file about this). WideAdd and WideMultiply do addition and multiplication of wides, and they are fairly self-explanatory, as are WideSubtract, WideSquareRoot, and WideNegate. Some of these routines return a WidePtr, which points to the wide parameter affected. In most cases, this is the destination wide (except for the WideShift calls, in which the pointer is to the source wide).

* WideDivide returns the quotient and WideWideDivide returns a pointer to the quotient. With WideWideDivide, you pass in a pointer to the dividend, and the quotient replaces the dividend when the function returns.

* WideCompare returns a value > 0 if parameter A is greater than parameter B, a value < 0 if parameter B is greater than parameter A, and 0 if the two are equal.

* WideBitShift is a raw, logical bit shift. Performing a shift of one bit to the right (decreasing) on a wide value of three returns a one with WideBitShift.

* WideShift rounds the result by adding half and truncating the decimal. Performing a shift of one bit to the right (decreasing) on a wide value of three returns two with WideShift. The actual value of the shift is 3/2 or 1.5, and the rounding done with WideShift rounds it up. The shift is to the right if the shift parameter is greater than 0, and to the left if < 0.

These functions aren't needed in the 68K environment, since the 'comp' data type can be used instead. Comps have 64 bits of precision and are taken care of automatically by SANE on the 68K environment. See page A-4 of the PowerPC numerics manual for a bit more information about the comp data type and its substitutions on the PowerPC. In general, the wide type and its operations should be used as a replacement.

[Jun 01 1995]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.