Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Incidentally, this is why UNIX uses zero for "success" and nonzero for errors.


Zero is not an indicator of success. It is a lack of failure (NULL). That distinction is why some people think the "flag" is inverted.


As per the principle, the lack of failure is how success can be measured.

ie Consequently, a successful endeavor (subject to this principle) is one where every possible deficiency has been avoided.


I always took this to be 'there is only one success, there are many failures', there is only one zero, but many values other than zero. It seemed kind of logical.


There is only one of any number.


That is true, in the pedantic sense but zero has many properties that other numbers do not.



> zero has many properties that other numbers do not

In particular, zero is the additive identity [0] in almost all the "usual" number systems in which it appears. That is roughly speaking, it is the only A such that X + A = X, for all X, where X and A are elements of the number system (e.g. field of real/complex numbers).

[0] https://en.wikipedia.org/wiki/Additive_identity


It's also the only real number that does not have an inverse element for multiplication (there is no number b such that (a * 0) * b = a)


The integers form a group under multiplication though and a key property of a group is that every element has an inverse. So how does the definition hold if there is nothing that could be considered an inverse for the number 0? Curious about this... I never thought about it before.


The integers do not form a group under multiplication. As you noticed, the multiplicative inverse of any integer other than 1 or –1 is not an integer.

You might be thinking of the rational numbers (excluding zero).


Woops. You're right.

Looks like I need to play Group or Not Group.

https://youtu.be/qvx9TnK85bw

But then even for addition what's the inverse of 0? -0?


You are thinking of the multiplicative group of integers coprime to some integer n. That set by definition never includes 0.


Integers form a monoid under multiplication.

PS: A monoid in which each element has an inverse is a group.


1 is the only A such that X + A = X + 1 :D


But all of them evaluate to true except for zero, thus one code for success, many for failure


That's idiomatic, not an inherent property of the numbers themselves. You're basically arguing that because we do it in one context we do it in another context, but it doesn't answer the question of why.


Well, an interesting fact is that every nonzero rational number has two equal representations in some bases, e.g. 0.999...=1. Zero is then is the only rational number with just one representation.

https://en.wikipedia.org/wiki/0.999...


You can represent 0 a countably infinite number of ways: 0 0.0 0.00 0.000 0.0000 ...


Well, the convention in maths is that we never add trailing zeros, since they wouldn't as any information. Unlike in other sciences, where they represent measurement precision.


The same is true of .999... and 1. In any case, it’s an artifact of how we represent numbers, not an property of the numbers themselves.


ähmm, no? Counterexample: 1/3

>every nonzero TERMINATING decimal has two equal representations


I mentioned "in some bases". In base 3, it's 0.1 and 0.0222...




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

Search: