Important: The information in this document is obsolete and should not be used for new development.
Converting Number Formats
You can use QuickDraw GX macros to convert betweenFixed
,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 aFixed
format and you can use theFloatToFixed
macro to convert from a floating-point format to aFixed
format. The functionality of theFloatToFixed
macro is also provided as the shortenedfl
macro. The functionality of theIntToFixed
macro is also provided as the shortenedff
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 theff
macro:
gxLine lineData = {ff(25), ff(25) , ff(125), ff(125)};than to use the equivalent, but much longerIntToFixed
macro:
gxLine lineData = {IntToFixed(25), IntToFixed(25), IntToFixed(125), IntToFixed(125)};For constants, usingff
is faster and more efficient than usingfl
, becauseff
is evaluated at compile time, whereasfl
is evaluated at run time.The
IntToFixed
macro is described on page 8-37. TheFloatToFixed
macro is described on page 8-39. Thefl
macro is described on page 8-39. Theff
macro is described on page 8-38.