3 ms·
> Isn't there an inherent need in programming to express an explicit "nothing" value? In numerical calculus: yes, most certainly. What do you expect the resul
by enriquto 8y ago
> Isn't there an inherent need in programming to express an explicit "nothing" value?
In numerical calculus: yes, most certainly. What do you expect the result of log(-1) to be? The alternative is to use specially tagged particular numbers as "no-data", and pray so that they do not appear naturally as the result of computations.
- da_chicken 8y agoSome systems already do that. C#'s Double type includes Double.NaN, Double.NegativeInfinity, and Double.PositiveInfinity. Math.Log(-1) does indeed return NaN.
- gpderetta 8y agoOr exceptions.
- kazagistar 8y agoTechnically, you could force the value to be one constrained to a valid range, rather then augmenting the domain, but this is a lot of work and maybe not worth it for pracial use.
- TheCoelacanth 8y agoThat doesn't mean numbers need to always be nullable. It means that `log` doesn't return a number, it returns a nullable number.
- syrrim 8y ago>What do you expect the result of log(-1) to be? i pi, or more generally i pi n for odd n.