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

feat: Support hexadecimal floating point literals #2460

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MaxGraey
Copy link
Member

@MaxGraey MaxGraey commented Aug 23, 2022

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`
  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@MaxGraey MaxGraey marked this pull request as draft August 23, 2022 17:43
@MaxGraey MaxGraey changed the title feat: Support hexadecimal float pointing literals feat: Support hexadecimal floating point literals Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant