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

[Feature] Support stringified via tags numeric literals #2480

Open
MaxGraey opened this issue Aug 28, 2022 · 0 comments
Open

[Feature] Support stringified via tags numeric literals #2480

MaxGraey opened this issue Aug 28, 2022 · 0 comments

Comments

@MaxGraey
Copy link
Member

MaxGraey commented Aug 28, 2022

Examples

const a = u32`0xFF` // same as u32(0xFF), <u32>0xFF, 0xFF as u32
const b = f64`-1e5` // ^
// etc

Motivation

It will allow support non-standard for TypeScript / JavaScript literal formats like hexadecimal floating points:

f64`0x1.2afep+34`
f32`0x1.0-2`

If you allow you to create custom tags, it could also be useful for third-party libraries. Possible examples:

u128`170141183460469231731687303715884105728`;
bigint`10889035741470030830827987437816582766592`;
deg`45`; // may convert to 0.7853981634 radians inplace
min`5`; // may convert to 300000 ms inplace 

For MVP we can implement only tags for builtin types without custom defined tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant