How to get the last digit of a big int in TypeScript

1 Answer

0 votes
// Declare the BigInt
const bigIntNumber: bigint = BigInt("12345678901234567890123456789012345");

// Perform modulo operation with another BigInt
const lastDigit: bigint = bigIntNumber % BigInt(10);

console.log(bigIntNumber); 
console.log(lastDigit);



/*
run:

12345678901234567890123456789012345n
5n

*/

 



answered Aug 27, 2025 by avibootz

Related questions

1 answer 82 views
1 answer 87 views
1 answer 72 views
1 answer 72 views
1 answer 90 views
1 answer 83 views
1 answer 71 views
...