Negative numbers | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Negative numbers

How would you express a negative number in coding

2nd Dec 2020, 4:46 PM
Meteor Destiny
Meteor Destiny - avatar
2 ответов
+ 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