Hacker News new | past | comments | ask | show | jobs | submit login

Why would you treat 0 as a prime number? It’s divisible by every integer.



That is circular reasoning.

If you start saying 0/x is 0 then of course 0/2 and 0/3 are zero. (Or equivalently that 0 x 2 = 0 x 3 = 0.) But that is an entirely different equivalence from factor reduction.

If you don’t start with that assumption and reduce 0/2 and 0/3 only according to shared factors, you find that all three numbers, 0, 2, and 3 can only be factored as a product of 1 and themselves.

(Thus a slightly generalized version of primes, for whole numbers instead of just natural numbers.)

So 0/2 and 0/3 are completely factor reduced.

The equivalence of 0/x = 0/2 = 0/3 = 0/1 = 0 is a separate equivalence. One which is not reversible, I.e. it erases information, and may break commutivity requiring special handling (exception generation, NaN representation, or calculation reordering, etc) if it is applied during intermediate calculations.

If you don’t apply the zero equivalence’s until a final value is calculated, you will always get the same answer, but will have avoided a need for special handling of intermediate calculations.

For instance, an intermediate division by zero followed by a multiplication of zero will cancel, avoiding any need to reorder calculations and yet resulting in the same final answer.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: