Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Environment and Utilities /
Chapter 8 - QuickDraw GX Mathematics / Using QuickDraw GX Mathematics


Converting Number Formats

You can use QuickDraw GX macros to convert between Fixed, fract, integer, floating-point, and gxColorValue number formats. Macros are also provided to round, truncate, and compute the square root of a fixed-point number.

For example, you can use the IntToFixed macro to convert an integer to a Fixed format and you can use the FloatToFixed macro to convert from a floating-point format to a Fixed format. The functionality of the FloatToFixed macro is also provided as the shortened fl macro. The functionality of the IntToFixed macro is also provided as the shortened ff macro.

The ff macro is especially useful when you are coding specific points in your application. For example, it's easier to define a line in your application using the ff macro:

gxLine lineData = {ff(25), ff(25) , ff(125), ff(125)};
than to use the equivalent, but much longer IntToFixed macro:

gxLine lineData = {IntToFixed(25), IntToFixed(25),
                   IntToFixed(125), IntToFixed(125)};
For constants, using ff is faster and more efficient than using fl, because ff is evaluated at compile time, whereas fl is evaluated at run time.

The IntToFixed macro is described on page 8-37. The FloatToFixed macro is described on page 8-39. The fl macro is described on page 8-39. The ff macro is described on page 8-38.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996