I'm coding a simple calculator just to get started with iPhone dev. The thing is I have a (-) button thats supposed to negate whatever is put to the screen already by doing a simple *-1
. It works fine except when the previous input is 0
.
Scenario: With empty screen or 0
, I tap (-) to negate. Then when I tap for example 9
I want it to read (or rather be) -9
. Not 9
as it is now. FYI I'm atm working with primitive ints everywhere but I'm prepared to abort that.
Questions: How to represent negative 0? Is there a data type I can use that supports it? NSInteger?
Or is the only way to do some hacky workaround with state boolean and stringWithFormat etc?
Appreciate the help. /O