A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-bigint-asintn-method/ below:

JavaScript BigInt asIntN() Method - GeeksforGeeks

JavaScript BigInt asIntN() Method

Last Updated : 12 Jul, 2025

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

Syntax: 

BigInt.asIntN(width, bigint);;

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

Return value: This method returns the value of bigint modulo 2width as a signed integer.

Below example illustrate the BigInt.asIntN() method in JavaScript:

Example 1: In this example, we will see the use of the BigInt.asIntN() 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.asIntN(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 use of the BigInt.asIntN() method in JavaScript.

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

Output: 

9223372036854775807n
-9223372036854775808n
-1n

We have a complete list of Javascript BigInt methods, to check those please go through the Javascript BigInt Complete Reference article.

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



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4