microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.62k stars 6.57k forks source link

[Run][Calculator Plugin] Support Hexadecimal calculations #3272

Closed dantler closed 1 year ago

dantler commented 4 years ago

Summary of the new feature/enhancement

It would be awesome if I could use PowerToys Run to do quick hexadecimal calculations.

Example input:

Example output:

With the implementation of this groundbreaking new feature, the common error of 0xG could be avoided.

Proposed technical implementation details (optional)

Utilize the Busy Wait Algorithm (BWA) so the user gets the feeling that the computer is thinking very hard.

Bounty

I will post one smiley face emoji upon completion of this task.

dnlmlr commented 4 years ago

I did not find this issue when creating my own. Still in my issue there were other features discussed (binary & conversion in particular), so I would suggest keeping the issue in mind when thinking about implementing this https://github.com/microsoft/PowerToys/issues/4690#issue-649753186

Summary of the new feature/enhancement

PT Run is already my goto way for doing small calculations. However I quite often need to do calculations, as well as conversions with different positional systems (mainly hex and binary). It would be great if the built in calculator would support hex numbers by using the 0xHH notations and binary numbers by using the 0bXX notation. The result could be presented in the same system that is used in the calculation. If the calculation is mixing systems (for example hex and decimal), the result might default to decimal instead. A conversion could also be implemented by using a notation similar to python-like casts: hex(some_numer), bin(some_number), dec(some_number).

Some possible calculation examples using the proposed system: 0xff + 0b100000000 -> 511 hex(0xff + 0b100000000) -> 0x1ff bin(0xac) -> 0b10101100 hex(674) -> 0x2a2

Joinyy commented 4 years ago

I also like the feature that Keypirinha has, that if I type some calculation I get multiple results with different formats:

> floor(16.5 * 1024) gives the result list:

             16407
            0x4017
0b0100000000010111
crutkas commented 3 years ago

this work item may solve this: https://github.com/microsoft/PowerToys/issues/2265 which will encompass https://github.com/microsoft/calculator/issues/526

Need to validate what items it will enable.

crutkas commented 1 year ago

PT Run can do this now. verified under 0.69.1 image

Joinyy commented 1 year ago

Would be nice if there was also hex output in a second row to choose from, especially when calculating multiple memory offsets or similar stuff I want to stay in hex for most calculations.

dantler commented 1 year ago

😀

zsynacl commented 1 year ago

encountered some problem when using hexademical calculation

29632

It would be great if someone can check what's going on.🌷

ukanuk commented 11 months ago

Also see #12571 and #27760, making PowerToys Run support programmer conversions would let me stop needing the Windows Calculator app. I regularly convert between binary, decimal, and hexadecimal for my work with Siemens and Rockwell PLCs for industrial automation (factory manufacturing). Bonus points if the common PLC number notations were also supported, e.g. 2#1111_1111 for binary, 8#7777_7777 for octal, and 16#FFFF_FFFF for hex. Lastly it would be nice if this were more clearly documented in PowerToys; I had no clue the Run dialog supported hex until I searched the Github and found this issue. I did try entering 16#80A4 into the run dialog but nothing happened, so I assumed there wasn't any support. Here are some representative calculations I currently do with Windows calculator and sites like https://www.rapidtables.com/convert/number/hex-to-decimal.html?x=80A4

Convert 1310 from decimal to binary for setting DIP switches for a Siemens F-Address: 1310 → 2#0101_0001_1110

Convert binary error code from raw device output into decimal for lookup in device manufacturer's error manual: 2#1101_1110 → 222 Atlas Copco Henrob "Die Check Camera: Ref. Image Does not Exist"

Convert unsigned decimal error code from raw device output into hexadecimal for lookup in device manufacturer's error manual: 32932 → 16#80A4 Siemens "The CPU does not support this function"

Convert signed decimal error code from raw device output into hexadecimal for lookup in device manufacturer's error manual: -32604 → 16#80A4 Siemens "The CPU does not support this function"

Jwiggiff commented 9 months ago

Any update on being able to convert bases? i.e. like what @dnlmlr said:

hex(674) -> 0x2a2