Changed result from type int to type long in order to ensure large resistance values can be calculated