WhiteBlackGoose / UnitsOfMeasure

Conceptual repo. Most advanced compile time safe units of measure for C# and F#
MIT License
57 stars 4 forks source link

Add more arithmetic operations and units #3

Open WhiteBlackGoose opened 2 years ago

WhiteBlackGoose commented 2 years ago

Operations

KillyMXI commented 2 years ago

I was going to open an issue for Sqrt, but since it is mentioned here I guess I can just comment here.

I've once had a problem that I tried to solve with F# and it's built-in units support. That didn't work out well because of Sqrt units involved. When dealing with noise in signal processing - it involves Sqrt(Hz) units for noise spectral density (random links: Wikipedia, some examples). If I try to introduce sqrtHz unit - it will become a base unit and inferred type for Hz will become sqrtHz^2 instead, which is very annoying. There was no way to enforce Hz as the base unit so I decided to scrap the whole idea and switch to C# completely for that project.

Also, Hz = 1/Second, but in certain domains you need Hz to be the base unit rather than Second.

WhiteBlackGoose commented 2 years ago

To make this possible I plan to add simplification of expressions. Just opened #8 . I'm not sure if it's going to be as smooth as one may wish, since we're playing with compile time magic.