Friday, September 5, 2025
HomeLanguagesJavascriptJavaScript BigInt asUintN() Method

JavaScript BigInt asUintN() Method

The BigInt.asUintN() method is an inbuilt method in JavaScript that is used to wrap a BigInt value to an unsigned integer between 0 and 2width-1.

Syntax:

BigInt.asUintN (width, bigint);

Parameters: This method accepts two parameters as mentioned above and described below:

  • width: This parameter holds the number of bits available for the integer size.
  • bigint: This parameter holds the integer to clamp to fit into the supplied bits.

Return value: This method returns the value of bigint modulo 2width as an unsigned integer.

Below examples illustrate the BigInt.asUintN() method in JavaScript:

Example 1: In this example, we will see the basic use of the BigInt.asUintN() method in JavaScript.

javascript




<script>
    let maxlimit = 2n ** (64n - 1n) - 1n;
       
    function GFG(num) {
      (num > maxlimit) ?
        console.log("Number exceed the limit "
               + "of signed 64-bit integer!"):
        console.log(BigInt.asUintN(64, num));
    }
       
    GFG(2n ** 16n);
    GFG(2n ** 32n);
    GFG(2n ** 64n);
</script>


Output:

65536n
4294967296n
"Number exceed the limit of signed 64-bit integer!"

Example 2: In this example, we will see the basic use of the BigInt.asUintN() method in JavaScript.

javascript




<script>
    const max = 2n ** (64n - 1n) - 1n;
       
    console.log(BigInt.asUintN(64, max));
    console.log(BigInt.asUintN(64, max + 1n));
    console.log(BigInt.asUintN(32, max));
</script>


Output:

9223372036854775807n
9223372036854775808n
4294967295n

Supported Browsers: The browsers supported by BigInt.asUintN() method are listed below:

  • Google Chrome 67 and above
  • Edge 79 and above
  • Firefox 68 and above
  • Opera 54 and above
  • Safari 14 and above
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11861 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS