Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inverting positive CGFloat to negative value

This might be a very dumb question, but if I have a CGFloat with value of 44.0, how do I make it to -44.0? I tried doing -myFloat and 0 - myFloat but it gives me 0. Why is this? Also I don't want a multiply by -1 answer

like image 604
xonegirlz Avatar asked Dec 13 '22 04:12

xonegirlz


1 Answers

Its very simple dude. Just multiply it with -1.

i.e. 44.0 * -1 = -44.0

Update:

Solution 2 as mentioned by Inafziger

yourNo = 0 - yourNo
like image 194
Janak Nirmal Avatar answered Jan 01 '23 22:01

Janak Nirmal