👨‍🏫 Meet William Kahan – The Man Who Tamed the Unknown

Back in the 1980s, William Kahan was on a secret mission. His goal? Fix how computers handle impossible or unknown calculations.

Inspired by stories from his mathematician father, he recalled one tale in particular: a genius mathematician whose lifelong equation was destroyed by a mysterious value. They called it “the devil’s number.”


đź§  The Problem: Weird Math That Breaks Code

Some operations confuse computers. Here are a few:

  • 0 / 0 → Division by zero
  • Math.sqrt(-1) → Square root of a negative
  • Math.log(-1) → Log of a negative
  • Math.acos(2) → Arccos of value > 1
  • Math.atan("hello") → Arctangent of a string
  • 5 * "hello" or 5 + "hello" → Mixing numbers and strings

All of these return something… but not what you’d expect.


💡 The Solution: NaN — Not-a-Number

Kahan’s breakthrough? A special value to represent “I don’t know what this is.”

He called it NaN — short for Not-a-Number.

This wasn’t just a label. It became the foundation of how computers handle impossible results.


🌍 The Impact: IEEE 754 Standard

NaN became a key part of the IEEE 754 standard — the global rulebook for how computers do math.

Thanks to Kahan, your code won’t crash when it hits strange math. It simply returns NaN, so your program can handle it smartly.


đź§Ş JavaScript in Action

Here’s how JavaScript handles some devilish math:

console.log(0 / 0);           // NaN
console.log(Math.sqrt(-1));   // NaN
console.log(5 * "hello");     // NaN
console.log(5 + "hello");     // "5hello" (string)

No explosions. Just NaN. That’s Kahan’s legacy in action.


🎉 Happy Birthday, William Kahan!

To the man who helped computers make sense of the senseless — thank you! Your work changed how we program, calculate, and code.

Here’s to you, the man who conquered the devil’s number.


<
Previous Post
Speed Up Your PHP Random Number Generation with Bitwise Operations
>
Next Post
đź§  Write Better Code with the 5-S Philosophy