Jump to content

Variable Logic of '123e5'


Recommended Posts

I have a doubt from the 'W3Schools' JS Tutorials, It is given below. The 'var y=123e5' produces 12300000.And 'var z=123e-5' produces 0.00123I did'nt understand what 'e5' and 'e-5' are stands for and how formed 12300000 from '123e5'and 0.00123 from '123e-5' ? The code given below. <script type="text/javascript">{var y=123e5;var z=123e-5;document.write(y+"<br/>"+z);}</script>

  • Like 1
Link to post
Share on other sites

It's a short form of scientific notation used in floating point numbers. The e represents 10 elevated to the number that follows it. 5e6 is the same as 5 * 106 or 5 * 1,000,000 = 5,000,000

  • Like 1
Link to post
Share on other sites
  • 7 years later...

var z=123e-5' produces 0.00123I

take "e" as "10*"
so 123e5 will be taken as 123 x 10*5 = 12300000

similary "e-" will be taken as "/10"

so 123e-5 becomes 123x 1/20*5 = 123/100000 = 0.00123

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...