AP_Math: add is_valid_octal helper function.

returns true if valid
This commit is contained in:
Tom Pittenger 2018-05-22 10:33:07 -07:00 committed by Tom Pittenger
parent c59be8bafe
commit 3653ba61d7
2 changed files with 21 additions and 0 deletions

View File

@ -237,3 +237,20 @@ Vector3f rand_vec3f(void)
return v;
}
#endif
bool is_valid_octal(uint16_t octal)
{
// treat "octal" as decimal and test if any decimal digit is > 7
if (octal > 7777) {
return false;
} else if (octal % 10 > 7) {
return false;
} else if ((octal % 100)/10 > 7) {
return false;
} else if ((octal % 1000)/100 > 7) {
return false;
} else if ((octal % 10000)/1000 > 7) {
return false;
}
return true;
}

View File

@ -249,3 +249,7 @@ float rand_float(void);
// generate a random Vector3f of size 1
Vector3f rand_vec3f(void);
// confirm a value is a valid octal value
bool is_valid_octal(uint16_t octal);