Difference between float and double in Arduino

ArduinoArduino BoardsArduino IDEArduino Programming Language

Float

  • Floating point numbers are stored using 4 bytes (32 bits).
  • Their max value can be 3.4028235E+38 and their min value can be -3.4028235E+38.
  • They have a precision of about 6-7 decimal places.

Double

  • While on several platforms, double has more precision than float. However, on most Arduino boards (Uno and many other ATmega boards), double has the same size as float. Arduino Due is an exception, wherein double has a size of 8 bytes (compared to 4 bytes of float).
  • On the boards where double is stored using 8 bytes, the max value can be 1.7*10^308 and the min value can be -1.7*10^308. On the boards where double is stored using 4 bytes, the max and min values are equivalent to float.
  • For the boards where double is stored using 8 bytes, the decimal precision is 14-15 places.
raja
Published on 24-Mar-2021 05:31:57
Advertisements