Skip to content

Commit

Permalink
AP_Declination: fixed rounding in mag field
Browse files Browse the repository at this point in the history
thanks to Angela for noticing this
  • Loading branch information
tridge committed Sep 3, 2021
1 parent 2e71c6f commit 71c5c62
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/AP_Declination/AP_Declination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ bool AP_Declination::get_mag_field_ef(float latitude_deg, float longitude_deg, f
bool valid_input_data = true;

/* round down to nearest sampling resolution */
int32_t min_lat = static_cast<int32_t>(static_cast<int32_t>(latitude_deg / SAMPLING_RES) * SAMPLING_RES);
int32_t min_lon = static_cast<int32_t>(static_cast<int32_t>(longitude_deg / SAMPLING_RES) * SAMPLING_RES);
int32_t min_lat = static_cast<int32_t>(static_cast<int32_t>(floorf(latitude_deg / SAMPLING_RES)) * SAMPLING_RES);
int32_t min_lon = static_cast<int32_t>(static_cast<int32_t>(floorf(longitude_deg / SAMPLING_RES)) * SAMPLING_RES);

/* for the rare case of hitting the bounds exactly
* the rounding logic wouldn't fit, so enforce it.
Expand Down

0 comments on commit 71c5c62

Please sign in to comment.