Skip to content

Commit

Permalink
[PHY] Fixed negative random numbers (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Jul 18, 2021
1 parent cb1d796 commit c843680
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/protocols/PhysicalLayer/PhysicalLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ int32_t PhysicalLayer::random(int32_t max) {

// create 32-bit TRNG number
int32_t randNum = ((int32_t)randBuff[0] << 24) | ((int32_t)randBuff[1] << 16) | ((int32_t)randBuff[2] << 8) | ((int32_t)randBuff[3]);
if(randNum < 0) {
randNum *= -1;
}
RADIOLIB_DEBUG_PRINTLN(randNum);
return(randNum % max);
}

Expand Down

0 comments on commit c843680

Please sign in to comment.