Real numbers in [0, 1] stored as scaled integers.
More...
|
| #define | PBL_RATIO32_MAX 65535 |
| | Scale of a ratio32, a uint32_t holding a real number in [0, 1].
|
| |
Real numbers in [0, 1] stored as scaled integers.
◆ PBL_RATIO32_MAX
| #define PBL_RATIO32_MAX 65535 |
Scale of a ratio32, a uint32_t holding a real number in [0, 1].
◆ pbl_ratio32_from_percent()
| static uint32_t pbl_ratio32_from_percent |
( |
uint32_t |
percent | ) |
|
|
inlinestatic |
Convert a percentage to a ratio32.
The result is one more than the truncated value, so it converts back to percent; 100 gives PBL_RATIO32_MAX + 1.
- Parameters
-
| percent | Percentage, 0 to 100. |
- Returns
- Ratio32.
References PBL_RATIO32_MAX.
◆ pbl_ratio32_to_percent()
| static uint32_t pbl_ratio32_to_percent |
( |
uint32_t |
ratio | ) |
|
|
inlinestatic |
Convert a ratio32 to a percentage.
- Parameters
-
- Returns
- Percentage, 0 to 100, truncated.
References PBL_RATIO32_MAX.