How does your programming language handle “minus zero” (-0.0)?
1–10 of 219 posts
Re: How does your programming language handle “minus zero” (-0.0)?
#2Re: How does your programming language handle “minus zero” (-0.0)?
#3Does anyone have a good example of a programming problem where we _need_ signed zero? Or where it makes things significantly simpler? As far as I know, there is no distinction between -0 and +0 in math, so I have never really understood why this is a thing in computers.
Re: How does your programming language handle “minus zero” (-0.0)?
#4Does anyone have a good example of a programming problem where we _need_ signed zero? Or where it makes things significantly simpler? As far as I know, there is no distinction between -0 and +0 in math, so I have never really understood why this is a thing in computers.
Re: How does your programming language handle “minus zero” (-0.0)?
#5Therefore; -0.0 + 2.0 = 2.0 and 0.0 + 2.0 = 2.0
Re: How does your programming language handle “minus zero” (-0.0)?
#6Elixir does not distinguish signs in zero, 0. Therefore; -0.0 + 2.0 = 2.0 and 0.0 + 2.0 = 2.0
Re: How does your programming language handle “minus zero” (-0.0)?
#7Does anyone have a good example of a programming problem where we _need_ signed zero? Or where it makes things significantly simpler? As far as I know, there is no distinction between -0 and +0 in math, so I have never really understood why this is a thing in computers.
If you've got two numbers, +0.0000001 and -0.0000001, but you can't represent that precision, can you see how it's less bad to round to +0.0000 and -0.0000 rather than to just 0.0000? It's encoding strictly more information.
Re: How does your programming language handle “minus zero” (-0.0)?
#8Elixir does not distinguish signs in zero, 0. Therefore; -0.0 + 2.0 = 2.0 and 0.0 + 2.0 = 2.0
Re: How does your programming language handle “minus zero” (-0.0)?
#9Does anyone have a good example of a programming problem where we _need_ signed zero? Or where it makes things significantly simpler? As far as I know, there is no distinction between -0 and +0 in math, so I have never really understood why this is a thing in computers.
Amusingly enough the Apple Watch reports temperature as 0° and sometimes as -0°, I've not determined what causes that, perhaps rounding around 0?
(Edit: no idea whether this applies to the Apple watch, it's just a use case for -0 with regards to temperature.)
Re: How does your programming language handle “minus zero” (-0.0)?
#10Does anyone have a good example of a programming problem where we _need_ signed zero? Or where it makes things significantly simpler? As far as I know, there is no distinction between -0 and +0 in math, so I have never really understood why this is a thing in computers.
Amusingly enough the Apple Watch reports temperature as 0° and sometimes as -0°, I've not determined what causes that, perhaps rounding around 0?
$ printf '%.0f°\n' 0.3
0°
$ printf '%.0f°\n' -0.3
-0°