negative-zero Questions
4
Solved
I know (-0 === 0) comes out to be true. I am curious to know why -0 < 0 happens?
When I run this code in stackoverflow execution context, it returns 0.
const arr = [+0, 0, -0];
console.log(M...
Stocking asked 22/12, 2021 at 14:9
4
Solved
In ruby why can I assign a negative sign to 0.0 float, is this feature useful in any way? Could someone explain this one to me?
-0.0
#=> -0.0
-0.0 * -1
#=> 0.0
Microvolt asked 4/11, 2019 at 10:28
4
Solved
Is there a way to write a type trait to determine whether a type supports negative zero in C++ (including integer representations such as sign-and-magnitude)? I don't see anything that directly doe...
Incriminate asked 23/2, 2019 at 8:5
2
Solved
I want to be able to test if zero is positive or negative in swift.
let neg: CGFloat = -0
let pos: CGFloat = +0
if pos == neg {
// this gets executed, but I don't want this
}
The code above does...
Carrell asked 25/10, 2018 at 7:4
2
Solved
This question demonstrates a very interesting phenomenon: denormalized floats slow down the code more than an order of magnitude.
The behavior is well explained in the accepted answer. Howev...
Kyanite asked 10/5, 2013 at 7:11
4
Solved
x = -0
>> -0
typeof(x)
>> "number"
x.toString()
>> "0"
console.log(x)
>> -0
How can I convert Javascript's −0 (number zero with the sign bit set rather ...
Teaspoon asked 13/2, 2018 at 10:30
1
Solved
I'm toying with some algorithm in Rust (though the language doesn't really matter for my question). Consider the code:
#[no_mangle]
pub fn test(x: f32) -> f32 {
let m = 0.;
x + m
}
fn main() ...
Parasympathetic asked 14/1, 2018 at 23:41
1
Solved
I came across this quirk while trying to optimise string pluralisation in a game of code golf. I had the idea to write strings as plurals and then use substr to cut the last character off, conditio...
Astonied asked 13/9, 2016 at 0:23
1
I have Double data type, cause I need result with floating number, but if my result is negative, it broke all my algorithm. Is there maybe a unsigned data type with floating point?
Collectivism asked 17/7, 2016 at 18:12
10
Solved
IEEE floating point numbers have a bit assigned to indicate the sign, which means you can technically have different binary representations of zero (+0 and -0). Is there an arithmetic operation I c...
Abstemious asked 23/2, 2011 at 19:25
4
Solved
Am I right that any arithmetic operation on any floating numbers is unambiguously defined by IEEE floating point standard? If yes, just for curiosity, what is (+0)+(-0)? And is there a way to check...
Thirlage asked 9/3, 2015 at 19:0
4
Solved
Why do doubles have -0 as well as +0? What is the background and significance?
Ainslee asked 24/11, 2012 at 18:42
1
© 2022 - 2024 — McMap. All rights reserved.