MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / get_twos_complement

Function get_twos_complement

libraries/AP_Math/AP_Math.cpp:571–577  ·  view source on GitHub ↗

get a twos-complement value from the first 'length' bits of a uint32_t With thanks to betaflight */

Source from the content-addressed store, hash-verified

569 With thanks to betaflight
570 */
571int32_t get_twos_complement(uint32_t raw, uint8_t length)
572{
573 if (raw & ((int)1 << (length - 1))) {
574 return ((int32_t)raw) - ((int32_t)1 << length);
575 }
576 return raw;
577}

Callers 1

_initMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected