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

Unit converter supports negative values #30776

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

Dub1shu
Copy link
Contributor

@Dub1shu Dub1shu commented Jan 6, 2024

Summary of the Pull Request

Fixes #30678
Allow unit converter to convert negative values.
For example, -10℃ is converted to 14℉.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Previous Unit Converter was not designed to accept negative values.
In the regular expression used to distinguish between numbers and non-numbers, the minus sign was treated as a non-number character. Modify to treat the minus sign as part of the number.

Validation Steps Performed

When you launch PowerToys Run and enter %%-10C to F, it displays 14℉

image

@Dub1shu
Copy link
Contributor Author

Dub1shu commented Jan 6, 2024

@microsoft-github-policy-service agree

@AzureArmageddon
Copy link

Thanks for working on my issue! Wondering if this PR does or if it should:

  • Allow temperatures below absolute-zero (0 Kelvin)?
  • Allow sub-zero values for non-temperature quantities?
    • Negative volumes?
    • Negative lengths?
    • Negative weights?

@Dub1shu
Copy link
Contributor Author

Dub1shu commented Jan 6, 2024

Hi there! Thanks for checking.
Regarding your questions:

  • Allowing temperatures below absolute zero (0 Kelvin):
    • It can convert temperatures below absolute zero.
    • I don't think we should allow temperatures below absolute zero. But this is an issue with UnitsNet, the library used within Unit Converter.
  • Allow sub-zero values for non-temperature quantities?:
    • Yes, this PR also supports conversion of negative values other than temperature.
    • As an example, the results for negative volume are shown below.
      image

Copy link
Collaborator

@jaimecbernardo jaimecbernardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the contribution!

@jaimecbernardo jaimecbernardo merged commit 3802e91 into microsoft:main Jan 17, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

[Bug][PowerToys Run] Unit Converter doesn't accept sub-zero/negative temperatures
3 participants