Mathematical and Logical Utilities

Introduction

You can use the Mathematical and Logical Utilities to perform mathematical and logical operations supported directly by the Mac OS. In particular, this chapter discusses how you can

• perform low-level logical manipulation of bits and bytes when using a compiler that does not directly support such manipulations

• save disk space by using simple compression and decompression routines

• obtain a pseudorandom number

• perform mathematical operations with two fixed-point data types supported directly by the Operating System

• convert numeric variables of different types

With the exception of the mathematical operations and conversions, these utilities are intended for programmers who occasionally need to access some of these features and do not require that the algorithms used to implement them be sophisticated. For example, if you are developing an advanced mathematical application, the pseudorandom number generator built into Mac OS might be too simplistic to fit your needs. Similarly, if you wish to access individual bits of memory in a time-critical loop, these routines are probably too slow to be practical.