Skip to content

"300 degC" wrongly converted to "300 K" by toSI() #3097

@jkotan

Description

@jkotan

The problem is related to #2499 but it was not fixed by the corresponding PR.

When we convert units from degC to K in SciCat they are wrongly converted by toSI() i.e. without adding the offset (SciCatProject/backend#926 ).

In physics you never use Celsius to describe a difference of two various temperatures by always Kelvin
so during conversion from degC to K the offset should be always added.

You can workaround the problem using twice unit() , to() and toSi() but it looks complicated.

Is this behavour expected?

To Reproduce

>  const { unit, version } = await import("mathjs");

> version
'12.1.0'

>  unit(300. "degC").toSI().toJSON()
{ mathjs: 'Unit', value: 300, unit: 'K', fixPrefix: true }

>  unit(300, "degC").to(unit("degC").toSI()).toJSON()
{ mathjs: 'Unit', value: 573.15, unit: 'K', fixPrefix: true }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions