KAPTEJNLN Posted July 20, 2011 Author Report Posted July 20, 2011 well back to the airbu as i wanted to update so it also have mach and that works but now it is the heading there shows 1 under. so would this work to on the heading HDG = math.floor(ipc.readLvar("AB_AP_HDG_Select") * 100) / 100 or is there another code for that. as i tryeid the code but it keeps showing hdg 1 degree under on the GOflight MCP. ?
Pete Dowson Posted July 20, 2011 Report Posted July 20, 2011 well back to the airbu as i wanted to update so it also have mach and that works but now it is the heading there shows 1 under. so would this work to on the heading HDG = math.floor(ipc.readLvar("AB_AP_HDG_Select") * 100) / 100 No, that is rounding down the .01 part,. Two things wrong there for a heading 1 under. First is that you don't need headings to 1/100th of a degree, second is that rounding down always reduces, never increases. That's why it is called rounding down. ;-) All you need to do is round up. To do that keep your current code but add 0.5 before display. It's really only simple arithmetic, not programming. ;-) Pete
KAPTEJNLN Posted July 21, 2011 Author Report Posted July 21, 2011 yes pete ofcause i think i Z z Z z Z It worked hdg = math.floor(0.5 + ipc.readLvar("AB_AP_HDG_Select_hist")) and yes when you say so i can se it is logic as take the variable and add 0.5 that would give if hdg 339,40+0.5 = 339,90 = 340. but also becaus you know what is posible to do in the lines. :smile:
Pete Dowson Posted July 21, 2011 Report Posted July 21, 2011 and yes when you say so i can se it is logic as take the variable and add 0.5 that would give if hdg 339,40+0.5 = 339,90 = 340. No, 339.4 gives 339 because the "math.floor" of 339.9 is 339. Only 339.5 and above will round up to 340. That's the point -- round up for .5 and above, down otherwise. That is "normal" rounding, or "rounding to nearest". Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now