Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to change the last 5 digits in a number?

I don’t know how it is possible for the number to have the last 5 digits … I will be very grateful for the help!

const num = 1666297292886;
//result 
1666297200000

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Adapt the 100000 with the same number of zeros you want.
Remove the last 5 zeros: divide by 1 and 5 zeros (100,000):

const num = 1666297292886;

const roundedDownResult = num - (num % 100000);
console.log(roundedDownResult);
const num = 1666297292886;

for (let i = 0; i < 10; i++) {
    var precisionFactor = Math.pow(10, i);
    console.log(num - (num % precisionFactor ));
}

If you want the opposite (the last 5 digits), use the following.

const num = 1666297292886;

const lastDigits = num - (Math.floor(num / 100000) * 100000);
console.log(lastDigits);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading