I'm learning Python and I wish to know why "-40//60 = -1" and "-40 % 60 = 20"
My solution to this problem was turning the values to positive, but I don't get why it is returning these values.
import math
class Clock:
def __init__(self, hour, minute):
self.hour = hour
self.minute = minute
self.extra_hour = 0
if self.minute >= 60:
self.hour += (self.minute // 60)
self.minute = (self.minute % 60)
while self.hour >= 24:
self.hour -= 24
if self.minute < 0:
self.hour -= int((math.sqrt(self.minute**2)//60) + 1)
self.minute = int(60 - (math.sqrt(self.minute**2) % 60))
while self.hour < 0:
self.hour += 24