Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check if a number is in exponential notation? [closed]

How can I check if number is exponential? I have a case in my code when adding or multiply integers, when usual number gets converted to exponential.

A rough example - 10000000*100000000000000000 will return 1e+24.

like image 272
Bohdan Srdi Avatar asked Feb 01 '26 14:02

Bohdan Srdi


1 Answers

Convert to a string and check for e.

let num = 10000000;
console.log(num.toString().includes('e'));

num *= 100000000000000000;
console.log(num.toString().includes('e'));
like image 69
isherwood Avatar answered Feb 04 '26 05:02

isherwood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!