Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scientific Units: Add inverse units #453

Closed
jtomanik opened this issue Feb 1, 2022 · 2 comments
Closed

Scientific Units: Add inverse units #453

jtomanik opened this issue Feb 1, 2022 · 2 comments
Labels
1.x.x expected somewhere in a future release component:scientific enhancement New feature or request

Comments

@jtomanik
Copy link
Contributor

jtomanik commented Feb 1, 2022

Describe the issue
When numeric numeric value is divided by a scientific unit a reciprocal unit should be returned.

For example, correct result of a calculation:
9 / (3kg) = 3(kg^-1)
image
source: https://www.wolframalpha.com/input/?i=9+%2F+%283kg%29

should be 3 (Reciprocal Kilogram).

Expected behavior
Operations resulting in reciprocal units should be implemented and operations that divide numerical values by scientific units should return correct units.

Additional context
The ability to divide numeric values by a scientific units was removed #445
This ticket was created in order to create a proper solution for those operations.

@jtomanik jtomanik added the 🐛bug Something isn't working label Feb 1, 2022
@jtomanik
Copy link
Contributor Author

jtomanik commented Feb 1, 2022

In #445 I have removed following:
assertEquals(3(Kilogram), 9 / 3(Kilogram)) from ScientificValueTest.kt

and

infix operator fun <
    Quantity : PhysicalQuantity,
    Unit : ScientificUnit<Quantity>
    > Number.div(unit: ScientificValue<Quantity, Unit>) = toDecimal() / unit

infix operator fun <
    Quantity : PhysicalQuantity,
    Unit : ScientificUnit<Quantity>
    > Decimal.div(unit: ScientificValue<Quantity, Unit>) = div(unit, ::DefaultScientificValue)

from ScientificValue.kt

@jtomanik jtomanik added component:scientific enhancement New feature or request and removed 🐛bug Something isn't working labels Feb 7, 2022
@jtomanik jtomanik changed the title Scientific Units: Properly handle inverse units Scientific Units: Add inverse units Feb 7, 2022
@Daeda88 Daeda88 added the 1.x.x expected somewhere in a future release label Feb 18, 2022
@Daeda88
Copy link
Contributor

Daeda88 commented Nov 13, 2023

Closing in favour of #712 which should support inversion

@Daeda88 Daeda88 closed this as completed Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x.x expected somewhere in a future release component:scientific enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants