jmeaster30 / MyLib

A C# library with some random stuff in it
MIT License
0 stars 0 forks source link

Measurement struct #8

Open jmeaster30 opened 4 months ago

jmeaster30 commented 4 months ago

I had this idea for my programming language I am making but it would be cool to have it wherever I can have it.

Basically, need a struct that can wrap numbers and gives the number a unit. Then write conversions between units and operators that check to make sure the units make sense and convert the values if the values' units are convertible between each other.

Can either do this with an enum that has all the units or do some inheritance magic to get it to work

Maybe we could have compound units?? Like how newtons are kg*m/(s^2) This would only be possible with multiplication and division