Negative numbers | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Negative numbers

How would you express a negative number in coding

2nd Dec 2020, 4:46 PM
Meteor Destiny
Meteor Destiny - avatar
2 Respostas
+ 4
Just like -150. You can check like if(num < 0) //negative number
2nd Dec 2020, 4:51 PM
AĶ¢J
AĶ¢J - avatar
+ 1
Just like AJ #Learn With Me šŸ‘Øā€šŸ’» said. You can Express negative numbers just like in maths. If you want to know how negative numbers are represented as binary inside machine language, then read next. The magnitude of the number is converted to 8bit binary, then its converted to 1's compliment, and then 2's compliment. Its a bit advanced concept.
2nd Dec 2020, 5:01 PM
Charitra
Charitra - avatar