rizonesoft / Notepad3

Notepad like text editor based on the Scintilla source code. Notepad3 based on code from Notepad2 and MiniPath on code from metapath. Download Notepad3:
https://www.rizonesoft.com/downloads/notepad3/
Other
4.91k stars 327 forks source link

Convert ouput of TinyExpr to hexadecimal? #5059

Open FCrane opened 9 months ago

FCrane commented 9 months ago

Hi! I've looked around but I can't find a way to convert a decimal number to hex (or binary or whatever) in Notepad3. Results of math expressions are always displayed in decimal and I can't find a way to change that... E.g.:

0x10 + 0xE = 30

Why??

Strangely enough there seems to be the function "hex", but it doesn't seem to do anything. E.g.

hex(10)=10

I'd expect it to convert the argument to hex format?

Is is possible to get hex output for math expressions in Notepad3? Unfortunately, there doesn't seem to be any documentation about these features in Notepad3 and the docs for TinyExpr library don't help either...

Thanks!

hpwamr commented 9 months ago

Is is possible to get hex output for math expressions in Notepad3?

Hello @FCrane , I don't thing it's possible. Maybe @RaiKoHoff can confirm it? 🤔 In my opinion, the main purpose of Notepad3 is to be a text editor and the calculator functionality is an incidental extra. Maybe you have other arguments?

Why not use the Free Windows calculator which can perfectly add Hex values and display the result in Hex. 😏

2023-11-22_094241

FCrane commented 9 months ago

Of course I know I can use Windows Calc, but I'm trying to avoid that, because it's not really comfortable to use. Integrating all basic things into one program (e.g. Notepad3) is much more convenient and since Notepad3 already supports most major math functions and number bases, it would be just logical that it also can display results in hex? Or at least provide a function to convert any number to hex (which the "hex()" function suggests but obviously it does not work). Maybe it's just a bug of the TinyExpr library or there is some feature not exposed by Notepad3 - anyway it would be nice if this could be added. Hex, binary and maybe octal (but that's not so important) are essential for programmers and since Notepad3 supports programming syntaxes and schemes, it would be perfect if it'd also support the needed number bases.

hpwamr commented 9 months ago

Hi @FCrane, I understand and agree with your argument. Let's wait for the response from "RaiKoHoff"... 🤔

nobk commented 9 months ago

HI, I come from another issue 4760 , and I made something that might be of interest to you. Time expression addition and subtraction calculations, time expressions converted to seconds, and integer Tinyexpr expressions are output in binary, octal, or hexadecimal systems. extexpr If anyone is interested and the project accepts this kind of PR, I can submit it. The source code is written in C++20, with a total of more than 300 lines. It has its own independent name space. I call it ExtendExpr. In the future, you can continue to expand the function, such as running python scripts in the text to generate C++ code, such as use python read small binary file and converted into a C++ array output to the source file. Or test regex in the text, or talk to chatgpt and receive answer in the text.