[PHY] Fixed negative random numbers (#328)
This commit is contained in:
parent
cb1d79621d
commit
c843680e07
1 changed files with 4 additions and 0 deletions
|
@ -159,6 +159,10 @@ int32_t PhysicalLayer::random(int32_t max) {
|
||||||
|
|
||||||
// create 32-bit TRNG number
|
// 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]);
|
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);
|
return(randNum % max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue