![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Johnnyfantastic6 |
this is the code im trying to make better:
func get_difference_between(number_one, number_two):
if number_one < 0:
number_one *= -1
if number_two < 0:
number_two *= -1
if number_one > number_two:
return number_one - number_two
else: return number_two - number_one
With this code, the difference between -5 and +6 is the same as between -5 and +4 (“1” in both cases). Is this really what you want?
Thomas Karcher | 2020-12-18 18:51
Do you need the sign of the number? You can use the sign function to figure that out.
Ertain | 2020-12-18 19:18