tiffany352 / rink-rs

Unit conversion tool and library written in rust
https://rinkcalc.app/about
GNU General Public License v3.0
408 stars 28 forks source link

dBm is missing #103

Open Kezii opened 2 years ago

Kezii commented 2 years ago

unit of power https://en.wikipedia.org/wiki/DBm

robryk commented 1 month ago

In general, dB{anyunit} (and plain unitless dB) would be nice but potentially challenging to handle. One would need to handle addition (dB{someunit} + dB{someotherunit} yields dB{someunit*someotherunit}) and probably forbid multiplication. Unit conversions from/to log units should be straightforward, but I suspect they might look confusing with standard operator precedence.

It might also be nice to actually handle B and {otherSIprefix}B, but OTOH I've nearly never saw those used.

tiffany352 commented 1 month ago

Yeah, it will require being handled specially in the syntax and come with a special data type. It will be similar to how temperatures (acting as postfix operators) and datetimes (acting as a special data type) are handled.

The nice thing is that once this special handling is added, it will be possible to reuse it for other non-linear scales, like pH and the Richter scale.

robryk commented 1 month ago

Do you have in mind making another variant of Value or extending Number?