4 ms·
BitInt's "n" suffix appears to stand for "numeric", but that seems confusing when typeof 1 === "number" and typeof 1n === "bigint". Why not an "i" suffix for "i
by cpeterso 7y ago
BitInt's "n" suffix appears to stand for "numeric", but that seems confusing when typeof 1 === "number" and typeof 1n === "bigint". Why not an "i" suffix for "integer"? I understand that a "b" suffix is probably reserved in case JavaScript adds support for binary literals.
https://tc39.github.io/proposal-bigint/#prod-BigIntLiteralSuffix https://tc39.github.io/proposal-bigint/#prod-BigIntLiteralSu...
- loeg 7y ago1i is a bit more difficult to read than 1n in many fonts. I don't think any numeral is plausibly confused with n, so 'iNt' makes some sense as a suffix IMO.
- GordonS 7y agoAs an aside, c# uses "L" to denote literals as 64-bit integers. "l" works too, but "L" is encouraged for the same reason you give ("l" could be confused as "1")
- matthewbauer 7y agoMaybe to avoid confusion with mathematical imaginary notation.
- ash_gti 7y ago'i' suffix are often used in languages for complex numbers. For example, in ruby '1i' evaluates to 0+1i as a complex number. I suspect they didn't want to conflate the two types.
- GordonS 7y ago64-bit integers are referred to as 'long' in languages I'm more familiar with, so personally I would have expected an "L" suffix. 32-bit integers are referred to as 'integers' in many languages, so I wouldn't expect an 'i' suffix. In any case, I certainly agree that "n" is confusing since Javascript already has a numeric type.
- vanderZwan 7y agoI suspect it is more that in mathematics, n is used to indicate integer values as opposed to for example x, which is used with real values.
- SomeOldThrow 7y ago> BitInt's "n" suffix appears to stand for "numeric" It actually stands for "not numeric"