From 227f4f5571f9fc343362f8ddb3ae6364494858e4 Mon Sep 17 00:00:00 2001 From: Joseph Poirier Date: Sun, 20 Dec 2015 16:16:52 -0600 Subject: [PATCH] use smallest possible var size --- main/traffic.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/traffic.go b/main/traffic.go index 75b6c87c..5ca46270 100644 --- a/main/traffic.go +++ b/main/traffic.go @@ -149,12 +149,12 @@ func makeTrafficReport(ti TrafficInfo) { // // Algo example at: https://play.golang.org/p/AQ0fpDudvi // - var alt int32 + var alt int16 if ti.Alt < -1000 || ti.Alt > 101350 { - alt = 0xFFF + alt = 0x0FFF } else { - // output guaranteed to be between 0x000 and 0xFFE - alt = int32((ti.Alt / 25) + 40) + // output guaranteed to be between 0x0000 and 0x0FFE + alt = int16((ti.Alt / 25) + 40) } msg[11] = byte((alt & 0xFF0) >> 4) // Altitude. msg[12] = byte((alt & 0x00F) << 4)