Commit fe8421e
committed
Human: Fix num2si dropping SI prefix for values in [1, 1000]
'num2si()' had an early-return shortcut for values already in [1, 1000)
that returned '{value}{base_unit}', discarding the SI prefix parsed from
the unit string. For example, 444.584 with unit "us" (sipfx="u",
base_unit="s") was returned as "444.58s" instead of "444.58us".
The early return is only valid when no SI prefix is present, i.e. the
value is already expressed in base units. Add 'not sipfx' to the
condition so prefixed units fall through to the full scaling logic.
Add test cases to 'test_num2si()' covering values in [1, 1000) with
SI-prefixed units (us, ms, mW).
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>1 parent 8130fe7 commit fe8421e
3 files changed
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
| 210 | + | |
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
201 | 220 | | |
202 | 221 | | |
203 | 222 | | |
| |||
0 commit comments