I am in need of a sentinel value to use to assign to a double variable initially. 0 or -1 won't work because these values are valid values in my computation and I need a value that will stand out.

Possible choices are:

  1. Maximum double value
  2. Minimum double value
  3. NAN (I would also need a method to check is_nan as well)

How can I accomplish this in the Arduino language?

  • AVR GCC doesn't technically support double at all. Commented Apr 29, 2016 at 18:00

1 Answer 1


This is a matter of personal preference. I like NAN because it is almost always obvious it cannot be a valid value.

You can test for the value being NAN with isnan().

  • Right but do they exist in arduino language? The constant NAN and isnan() function (in standard c++ it's a std:: library function) Commented Apr 30, 2016 at 3:22
  • The link I provided is to the doc of the avr-libc. You can use NAN and isnan() with no prefix on any AVR-based Arduino. No need to explicitly include <math.h>, as the Arduino IDE does that for you (via <Arduino.h>). I do not know about the ARM-based Arduinos (e.g., the Due). Commented Apr 30, 2016 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.