- lon_frac = (longitude + 50000) / 100000;
-
- c = sprintf ((char *) tncBufferPnt, "=%02u%02u.%02u%c\\%03u%02u.%02u%cO /A=%06u\015",
- lat_deg, lat_min, lat_frac, lat_sign,
- lon_deg, lon_min, lon_frac, lon_sign,
- altitude * 100 / 3048);
- tncBufferPnt += c;
- tncLength += c;
+ lon_frac = longitude / 100000;
+
+ if (altitude < 0)
+ altitude = 0;
+
+ altitude = (altitude * (int32_t) 10000 + (3048/2)) / (int32_t) 3048;
+
+ return sprintf ((char *) tncBuffer, "=%02u%02u.%02u%c\\%03u%02u.%02u%cO /A=%06u\015",
+ lat_deg, lat_min, lat_frac, lat_sign,
+ lon_deg, lon_min, lon_frac, lon_sign,
+ altitude);