winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.07k stars 198 forks source link

Support BigInt #6261

Open skyrpex opened 7 months ago

skyrpex commented 7 months ago

Use Case

BigInt values represent numeric values which are too large to be represented by the number primitive.

It's a basic data type for many kind of application. Additionally, some libraries in the ecosystem require the use of bigints, such as tigerbeetle-node.

Proposed Solution

I'd adopt the JS syntax to manage bigints:

let previouslyMaxSafeInteger = 9007199254740991n;

let alsoHuge = BigInt(9007199254740991);
// 9007199254740991n

let hugeString = BigInt("9007199254740991");
// 9007199254740991n

let hugeHex = BigInt("0x1fffffffffffff");
// 9007199254740991n

let hugeOctal = BigInt("0o377777777777777777");
// 9007199254740991n

let hugeBin = BigInt(
  "0b11111111111111111111111111111111111111111111111111111",
);
// 9007199254740991n

Take a look at JS's BigInt operators and comparisons. Also, the conditionals.

Implementation Notes

JavaScript provides good support for them, so implementing them in Wing should be straightforward.

Component

No response

Community Notes

github-actions[bot] commented 4 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!