assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

feat: Support hexadecimal floating point literals

Open MaxGraey opened this issue 3 years ago • 0 comments

Examples

0x1.999999999999ap-4
-0X0.1P4
-0x1A.p+100

Motvation

  • Hexadecimal float pointing literals can represent float points exactly without complicated and expensive parsing. It's quite useful for math calculations;
  • Hexadecimal float pointing format supported in many languages (C, C++, Julia and etc). Therefore, support for this format makes it easier migration;
  • Hexadecimal float pointing format supported by WebAssembly spec. And since we support the same things as WebAssembly, it makes sense to add support to the language itself.

~~As always, the TS language doesn't support such literal format, so as usual we can use the standard way (@ts-ignore) to mute ts checker.~~

Firstly, we need to add built-in literal templates like:

f64`0x1.999999999999ap-4`
i32`123`
  • [x] I've read the contributing guidelines
  • [x] I've added my name and email to the NOTICE file

MaxGraey avatar Aug 23 '22 17:08 MaxGraey