thold_display_to_raw() and thold_raw_to_display() disagree, so opening a threshold and saving it again can change its value by a factor of 1000.
Confirmed by running both functions:
display_to_raw('5p') => 5.0E-9 (pico is 1e-12)
display_to_raw('5f') => 5.0E-15
raw_to_display(5.0E-9) => '5p'
raw_to_display(5.0E-12) => '5f'
raw_to_display(5.0E-15) => '5' + PHP warning
The suffix tables do not match
thold_display_to_raw() (thold_functions.php:5309-5311) maps p to 1e-9 and f to 1e-15. thold_raw_to_display() uses the pattern 'mupf', i.e. m=1e-3, u=1e-6, p=1e-9, f=1e-12.
Two separate problems fall out:
p is wrong in both. Pico is 1e-12, not 1e-9. A threshold entered as 5p is stored as 5e-9.
- The round trip loses a factor of 1000 at
f. raw_to_display(5e-12) gives '5f', and feeding '5f' back through display_to_raw gives 5e-15. Opening a threshold in the UI and saving it without changing anything divides it by 1000.
Reading past the end of the pattern
For values beyond about 1e27 or below 1e-12, thold_raw_to_display() indexes $pattern[$count - 1] past the end (:5616):
Warning: Uninitialized string offset 4 in thold_functions.php on line 5616
The suffix comes back empty, so the magnitude is silently dropped — 5e-15 renders as 5.
The docblock agrees with neither
The block at :5359-5377 documents f as 10e-12 and p as 10e-9, and sits above thold_raw_to_display() while describing thold_display_to_raw().
A single shared constant map for both directions, plus bounds checks, would make the pair inverses and let a round-trip property test hold.
thold_display_to_raw()andthold_raw_to_display()disagree, so opening a threshold and saving it again can change its value by a factor of 1000.Confirmed by running both functions:
The suffix tables do not match
thold_display_to_raw()(thold_functions.php:5309-5311) mapspto 1e-9 andfto 1e-15.thold_raw_to_display()uses the pattern'mupf', i.e.m=1e-3,u=1e-6,p=1e-9,f=1e-12.Two separate problems fall out:
pis wrong in both. Pico is 1e-12, not 1e-9. A threshold entered as5pis stored as 5e-9.f.raw_to_display(5e-12)gives'5f', and feeding'5f'back throughdisplay_to_rawgives 5e-15. Opening a threshold in the UI and saving it without changing anything divides it by 1000.Reading past the end of the pattern
For values beyond about 1e27 or below 1e-12,
thold_raw_to_display()indexes$pattern[$count - 1]past the end (:5616):The suffix comes back empty, so the magnitude is silently dropped — 5e-15 renders as
5.The docblock agrees with neither
The block at
:5359-5377documentsfas 10e-12 andpas 10e-9, and sits abovethold_raw_to_display()while describingthold_display_to_raw().A single shared constant map for both directions, plus bounds checks, would make the pair inverses and let a round-trip property test hold.