Skip to content

Commit

Permalink
Merge pull request #604 from electro-smith/fix/randfloat
Browse files Browse the repository at this point in the history
Fix float range for `Random::GetFloat`
  • Loading branch information
beserge authored Feb 21, 2024
2 parents 9e8cac6 + 443f170 commit 0b221a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/per/rng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ uint32_t Random::GetValue()

float Random::GetFloat(float min, float max)
{
float norm = (float)GetValue() / 0x7fffffff;
float norm = (float)GetValue() / (float)0xffffffff;
return min + (norm * (max - min));
}

Expand All @@ -49,4 +49,4 @@ bool Random::IsReady()
return ((RNG->SR & RNG_FLAG_DRDY) == RNG_FLAG_DRDY) == SET;
}

} // namespace daisy
} // namespace daisy

0 comments on commit 0b221a4

Please sign in to comment.