Double and float

Double and float data types are floating point numbers which means they are numbers that can contain a decimal point. Both the double and float types can hold values ranging from -3.4028235E+38 to 3.4028235E+38.

On most platforms, the float data type has a precision of six or seven decimal digits while the double data type usually has fifteen digits; however, this is not true on the Arduino platform. On the Arduino platform, the double and float types are exactly the same, therefore they both have the precision to six or seven decimal digits.

There are two very good reasons not to use a double or float value unless you absolutely need a decimal number. The first reason is with precision inaccuracy, as an example 6.0 divided ...

Get Mastering Arduino 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.