Reason for using floats as values in a while loop #387

Closed
opened 2023-02-19 15:04:47 +01:00 by gaisser · 2 comments
Member

Is there a specific reason why you are using floats in this loop?

This increments k and l before the user code. Is this a matlab export?

Also index is a uint8_t and k and l are almost 1.0, 2.0, 3.0 but also might be 2.99999. which might result in a wrong index. (I don't think that this is the case here but it looks strange to me)

void SusConverter::calibration(const float coeffAlpha[9][10], const float coeffBeta[9][10]) {
  uint8_t index;
  float k, l;

  // while loop iterates above all calibration cells to use the different calibration functions in
  // each cell
  k = 0;
  while (k < 3) {
    k++;
    l = 0;
    while (l < 3) {
      l++;
Is there a specific reason why you are using floats in this loop? This increments k and l before the user code. Is this a matlab export? Also index is a uint8_t and k and l are almost 1.0, 2.0, 3.0 but also might be 2.99999. which might result in a wrong index. (I don't think that this is the case here but it looks strange to me) ``` c++ void SusConverter::calibration(const float coeffAlpha[9][10], const float coeffBeta[9][10]) { uint8_t index; float k, l; // while loop iterates above all calibration cells to use the different calibration functions in // each cell k = 0; while (k < 3) { k++; l = 0; while (l < 3) { l++; ```
gaisser added the
question
label 2023-02-19 15:04:47 +01:00
meggert was assigned by muellerr 2023-02-19 16:16:09 +01:00
Owner

Not sure why the increments are done before the user code. It's more or less a straight copy from a student thesis.

344ced60d3/src/sus_converter.cpp (L195-L258)

I'm pretty sure, I changed k and l to uint8_t before but reverted that change because I simply was too lazy to change the equations used in the if conditions which would then consist only of ints but require a division.

Not sure why the increments are done before the user code. It's more or less a straight copy from a student thesis. https://egit.irs.uni-stuttgart.de/eive/sus-raw-to-vec/src/commit/344ced60d33e11039bb962c8f999f15af709a511/src/sus_converter.cpp#L195-L258 I'm pretty sure, I changed k and l to uint8_t before but reverted that change because I simply was too lazy to change the equations used in the if conditions which would then consist only of ints but require a division.
Owner

fixed with #394

fixed with https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/394
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: eive/eive-obsw#387
No description provided.