Extended Numeric Literals
See original GitHub issueSearch Terms
- extended-numeric-literals
- extended numeric literals
Suggestion
Support tc39/proposal-extended-numeric-literals (Stage 1)
Use Cases
For represent lengths in pixels, inches, degrees, radians, seconds and other units without calling specifically conversion methods in runtime (if this possible).
const time = 100s // transforms to `100,000` ms
const angle = 180° // transforms to `3.1415926536` radians
Examples
function deg(value: number): number {
return value * (Math.PI / 180);
}
function °(value: number): number {
return deg(value);
}
function _f32(value: number): number {
return Math.fround(value);
}
function _u32(value: number): number {
return value >>> 0;
}
function px(value: number): string {
return `${ value }px`;
}
var angle = 30deg; // transforms to `0.5235987756`
const angle2 = 180°; // transforms to `pi` (`3.1415926536`)
let count = 1_000_000_u32;
var float32 = 1.0_f32;
canvas.style.width = 512px; // transforms to "512px" string
Also related to #15096
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
tc39/proposal-extended-numeric-literals - GitHub
Numeric literal suffixes live in a parallel lexical scope. Entries can be created in the scope with a SuffixDeclaration , of the form...
Read more >Extended Numeric Literals - TC39
This document is a Stage 1 draft specification for extended numeric literals in JavaScript. For a high-level overview of the design, ...
Read more >Integer literal - cppreference.com
The type of the integer literal is the first type in which the value can fit, from the list of types which depends...
Read more >Numeric Literals - Embedded.com
0x3FL has type (signed)long int .An integer literal suffix may combine U with either L or LL (in either upperor lower case and...
Read more >Underscores in Numeric Literals
Underscores in Numeric Literals. In Java SE 7 and later, any number of underscore characters ( _ ) can appear anywhere between digits...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is already used with the arrival of BigInt. And with success has taken hold in such modern languages like Rust, Ruby, Swift
@MaxGraey Yes it is