IF ((ABS LAT) < 35) AND ((ABS LONG) < 35) THEN 'Don't need to do precise calculation unless close, prevents overflow Distance = SQR((LAT * LAT) + (LONG * LONG)) ELSE Distance = (ABS LAT) + (ABS LONG) 'Rough distance calculation that won't overflow ENDIF DEBUG "Distance: ",DEC Distance,CR DO WHILE ((ABS LAT) > 127) OR ((ABS LONG) > 127) 'Need to be < 127 for ATN to work, divide by 2 until small enough IF LAT.BIT15 = 1 THEN ' Check for negative LAT = (ABS LAT)/2 ' Negative - divide by 2 and negate LAT = -LAT ELSE LAT = LAT/2 'Not negative divide by 2 ENDIF IF LONG.BIT15 = 1 THEN 'Check Delta-Long for negative LONG = (ABS LONG)/2 'Negative - divide by 2 and negate LONG = -LONG ELSE LONG = LONG/2 'Divide by 2 positive ENDIF LOOP