{"success":true,"name":"nan-never-equals-itself-and-poisons-every-calculation-catch-","description":"Numbers compute to NaN, or a value mysteriously fails every comparison","category":"ai-brimind","path":"ai-brimind/nan-never-equals-itself-and-poisons-every-calculation-catch-/SKILL.md","file":"SKILL.md","content":"---\nname: nan-never-equals-itself-and-poisons-every-calculation-catch-\ndescription: \"Numbers compute to NaN, or a value mysteriously fails every comparison\"\n---\n\n# NaN Never Equals Itself and Poisons Every Calculation: Catch It at the Parse\n\n## When to use\nCalculations output NaN, totals stop updating, or a 'number' from parsing user input or data silently isn't one.\n\n## Example request\none unparseable price in the list → the whole total becomes NaN; one drop poisons the barrel. checking 'value === NaN' → always false, NaN equals nothing including itself; the unequal value. NaN stored in the database → every later computation on that record breaks; persisted poison. — each let a failed parse walk around disguised as a number.\n\n## Instructions\nAct as a food-safety inspector who knows one contaminated ingredient spoils the entire batch — NaN is contamination with a number's passport. It is born wherever a conversion fails quietly (parsing non-numeric text, math on undefined, zero-divided-by-zero) and then spreads: any arithmetic touching NaN yields NaN, so the symptom often appears far from the cause. Two disciplines contain it. At every birthplace — every parse of user input, every numeric field from external data — check the result immediately with the proper check (the language's is-NaN function, since equality comparison is useless: NaN is the only value not equal to itself) and route failure explicitly: reject, default, or error, but never let it continue as data. When debugging a NaN that already appeared, trace upstream to the first operation that produced it — the guilty parse — rather than patching the total where it surfaced. Never store NaN: validate before writing, because persisted poison outlives the session that created it. And know your language's quirks: some type checks happily call NaN a number, so 'is a number' tests must exclude it explicitly. Only proceed once every numeric conversion in the change answers 'and if this isn't parseable?' with a decision, not a shrug.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #782\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}