Another Native Data Type
We've used almost all the native data types, but there is one other native type that you might see in other programs and in other textbooks, so I should tell you about it now. This other native type is float, which, like the double type we've already seen, is used to store values that can contain fractional parts, (so-called floating-point numbers). Why are there two of these types rather than only one? The main difference between float and double is that the implementation of float in most compilers takes less memory than the implementation of double; typically floats are 4 bytes long and doubles are 8 bytes long. As a result, a double can store larger values and maintain higher accuracy. However, the greater memory ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access