How to convert an integer to a string in base b with TypeScript

1 Answer

0 votes
const num = 255;
const base = 16; // Convert to hexadecimal (base 16)

let result: string = num.toString(base).toUpperCase();

console.log(result);




/*
run:

"FF" 

*/

 



answered Aug 18, 2025 by avibootz
...