+ 27

[Solved] How the answer is -0?😨

I just wrote a simple program in c++ . My code is: https://code.sololearn.com/cOSdnLC3MUgJ/?ref=app I became surprised when I saw the answer is -0. Thanks in advanced.

1st Sep 2020, 9:37 AM
The future is now thanks to science
The future is now thanks to science - avatar
15 Answers
+ 10
Web-Learner From mathematical point of view, -0 and 0 is same number. So it should automatically transfered to 0.
1st Sep 2020, 9:50 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 8
Tanitoluwa Winter please don't spam in Q&A.
3rd Sep 2020, 10:44 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 7
Tanitoluwa Winter please don't spam .
3rd Sep 2020, 10:36 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 4
It though may not satisfy you, but it's an interesting post I found (Not related to C++) https://softwareengineering.stackexchange.com/questions/280648/why-is-negative-zero-important
1st Sep 2020, 10:02 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 3
Because you didn't used absolute value for c
1st Sep 2020, 9:38 AM
Nihar Buliya
Nihar Buliya - avatar
+ 3
From a mathemitacal point of view, 10/5=2 -10/5=-2 So: -0/5=-0
1st Sep 2020, 9:47 AM
Web-Learner
+ 2
Beacause 0 is divide by any number it gives 0 and there is in negetive so answer is also negetive
2nd Sep 2020, 9:04 AM
Harshit Singh
Harshit Singh - avatar
+ 2
Because you not used there another value..
2nd Sep 2020, 1:01 PM
Pathan Nishad Amir
Pathan Nishad Amir - avatar
+ 2
-0 "might" means that you have reached the value "zero" from lower numbers. But in school I've always found written 0¯. So I don't know.
2nd Sep 2020, 5:55 PM
Gabriele Gatti
Gabriele Gatti - avatar
+ 2
Tanitoluwa Winter ,please don't ask question in the answer of a question .If you need any help about programming related or about sololearn you can ask in Q&A discussion but make sure use the search bar before posting any question. If you don't understand the sololearn forum you can see this: https://www.sololearn.com/post/52212/?ref=app https://www.sololearn.com/post/432150/?ref=app
3rd Sep 2020, 9:26 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
-0 & 0 is same
2nd Sep 2020, 9:45 AM
Estiak Hasan Raj
Estiak Hasan Raj - avatar
+ 1
Because you used b= -5 , a/b =0/-5 = -0 Maybe I am wrong
3rd Sep 2020, 2:24 AM
★Achintya★
★Achintya★ - avatar
+ 1
Very Good Find its really intriguing question.
3rd Sep 2020, 2:25 AM
🐋Joey 🦓...🦅
0
you should just use absolute value for c but only in case which a is 0
2nd Sep 2020, 2:09 PM
Panos PaP
Panos PaP - avatar