Suggestion: Drop the signbit #142
Comments
This doesn't affect existing code unless someone adds new code to the page, so no, it wouldn't break the web. There may be existing code whose assumptions are no longer valid in the presence of new code, but that's true for many features. I don't think avoiding this hazard is worth not having negative integers. |
What would this mean? |
Ok. So why forbid |
It means that we can make BigInt unsigned since as a basis feature for scientific calculations, natural number is enough. |
See #25. |
I mean otherwise it should be: +0n === 0n |
Without signbit, BigInt would become compatible with |
Quite strange: String(0); // "0"
String(0n); // "0"
-{[Symbol.toPrimitive]: hint => {
throw new EvalError(hint);
}}; // EvalError: number
-{[Symbol.toPrimitive]: () => "0"}; // -0
-{[Symbol.toPrimitive]: () => 0n}; // 0n
typeof 0n; // "bigint"
+{[Symbol.toPrimitive]: () => 0n}; // TypeError: Cannot convert a BigInt value to a number |
These were all explicit design decisions, and I don't see any reason in this thread to change things. Feel free to reopen with more motivation. |
Closed because the proposal seems not going to separate number and bigInt completely. |
Before BigInt, the following usual equivalent implementations can all convert
a
to a number unless throw:Now:
Suggestion: Drop the signbit of BigInt
The text was updated successfully, but these errors were encountered: