Skip to content

How to add unit with no linear conversion? #25

@labordep

Description

@labordep

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions