mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-16 08:21:36 +00:00
Fixed potential bugs
This commit is contained in:
parent
a6ef9a58ec
commit
3431320d03
4 changed files with 8 additions and 5 deletions
|
|
@ -59,10 +59,10 @@ class SIFormatter
|
|||
$prefixes_neg = ['', 'm', 'μ', 'n', 'p', 'f', 'a', 'z', 'y'];
|
||||
|
||||
if ($magnitude >= 0) {
|
||||
$nearest = (int) floor(abs($magnitude) / 3);
|
||||
$nearest = min((int) floor(abs($magnitude) / 3), count($prefixes_pos) - 1);
|
||||
$symbol = $prefixes_pos[$nearest];
|
||||
} else {
|
||||
$nearest = (int) round(abs($magnitude) / 3);
|
||||
$nearest = min((int) round(abs($magnitude) / 3), count($prefixes_neg) - 1);
|
||||
$symbol = $prefixes_neg[$nearest];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue