AP_Math: add is_valid_octal helper function.
returns true if valid
This commit is contained in:
parent
c59be8bafe
commit
3653ba61d7
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user