13.3. Arbitrary-Precision Numbers

Doubles are usually sufficiently precise for any numerical analysis you may wish to perform. However, PHP offers a way to work with numbers of much higher precision. The functions in this section use strings to store very long floating-point numbers. They each use a scale value that is the number of digits to the right of the decimal point. The scale argument that appears in all of the functions is optional and will override the default scale. The bcscale function, described in Chapter 15, sets the default scale.

These functions are part of the bcmath extension. They are part of the binary distribution for Windows, but they are not activated by default for other operating systems. If PHP reports these functions ...

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.