Image for NaN (Not a Number)

NaN (Not a Number)

NaN (Not a Number) is a value used in computing to represent an undefined or unrepresentable numerical result, such as dividing zero by zero or taking the square root of a negative number. It signals that a calculation didn't produce a valid number. NaN is not equal to any number, including itself, and helps programs handle errors or special cases without crashing. Think of NaN as a placeholder indicating "this calculation didn't produce a meaningful number" within mathematical operations in software.