Byte arrays and math
G'day all,
This is for an SX28.
I have an byte array with·3 fields
ie;
gpsknots·· VAR·· Byte(2)
speed······ VAR·· Byte
where;
· gpsknots(0) = 1
· gpsknots(1) = 4
· gpsknots(2) = 3
To put this in a single variable i can use in operations i came up with this;
· speed = 0
· tmpB1 = gpsknots(0) * 100
· tmpB2 = gpsknots(1) * 10
· tmpB3 = tmpB1 + tmpB2
· speed = gpsknots(2)
· speed = speed + tmpB2
· speed = speed + tmpB1·
I'm still playing around with the code and haven't tested anything yet but can someone tell me if this will work and if its efficient?
Cheers!
This is for an SX28.
I have an byte array with·3 fields
ie;
gpsknots·· VAR·· Byte(2)
speed······ VAR·· Byte
where;
· gpsknots(0) = 1
· gpsknots(1) = 4
· gpsknots(2) = 3
To put this in a single variable i can use in operations i came up with this;
· speed = 0
· tmpB1 = gpsknots(0) * 100
· tmpB2 = gpsknots(1) * 10
· tmpB3 = tmpB1 + tmpB2
· speed = gpsknots(2)
· speed = speed + tmpB2
· speed = speed + tmpB1·
I'm still playing around with the code and haven't tested anything yet but can someone tell me if this will work and if its efficient?
Cheers!
Comments
speed = speed + gpsknots(1)
speed = speed * 10
speed = speed + gpsknot(2)
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
Post Edited (JonnyMac) : 9/20/2008 12:56:44 AM GMT