dynamicexpresso / DynamicExpresso

C# expressions interpreter
http://dynamic-expresso.azurewebsites.net/
MIT License
2.01k stars 379 forks source link

HEX (0x) or binary (0b) value support #236

Closed mocakturk closed 2 years ago

mocakturk commented 2 years ago

Library does not support hex number (e.g. 0xABC) or binary number (e.g. 0b1101). I need to replace hex/binary numbers using regular expression before evaluation.

Here example expression: "4 + 0xA1"

The result should be 165.

metoule commented 2 years ago

Relevant documentation: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#6453-integer-literals

metoule commented 2 years ago

I've created a pull request to support hexadecimal and binary literals. I didn't add support for the underscore decoration, so you can write 0b1111, but not 0b11_11.