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

How to add unit with no linear conversion? #25

Open
labordep opened this issue Nov 6, 2024 · 2 comments
Open

How to add unit with no linear conversion? #25

labordep opened this issue Nov 6, 2024 · 2 comments

Comments

@labordep
Copy link

labordep commented Nov 6, 2024

Hi @MarcusDenker!
I'm trying to implement the decibel unit.
This is based on the watt but without a "linear" conversion. The conversion from db to w is

10 raisedTo: (db-30 / 10)

I'm adding a new unit with this value in watt:

self
		abbreviation: 'dB'
		name: 'decibel'
		pluralName: 'decibels'
		value: ((10 raisedTo: ((1 - 30) / 10)) units: Unit watt). 

but when I'm trying to convert 30dB in Watt this is 0.3w and not 1 (because 30dB=1W):

30 decibel convertTo: #watt =>0.037767762353824993 watts

I suppose this is normal and I don't know how to write the conversion formula (and also the reverse too).

How I can implement that?

Thanks.

@MarcusDenker
Copy link
Member

Sorry for the late answer. I have sadly no idea myself, I will have a look as soon as I find time

@labordep
Copy link
Author

Thanks @MarcusDenker, interessed to take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants