본문 바로가기
javaScript/JS Tutorial

[자바스크립트]number 지수 표기 123e5

by mooyou 2022. 9. 28.
728x90
300x250

javaScript는 오직 한가지 타입의 number만 가지고 있다.

number는 소수점을 포함하거나 포함하지 않고 사용할 수 있다.

 

let x = 3.14;    // A number with decimals
let y = 3;       // A number without decimals

 

이 때 매우 크거나 작은 수는 지수를 이용한 과학적 표기법으로 작성할 수 있 다.

<p id="demo"></p>

<script>
    let x = 123e5;
    let y = 123e-5;
    document.getElementById("demo").innerHTML = x + "<br>" + y;
</script>

실행결과

12300000
0.00123

 

123e5에서 e는 뒤에 오는 숫자로 10을 올린 것을 나타낸다. 즉 123e5는 123 * 10⁵ 를 나타닌다.
계산하면 123*100,000 = 12300000

e-는 /10으로 간주 된다.
따라서 123e-5는 123 * 1 / 10 * 5 = 123 / 100000 = 0.00123

 

과학적 표기법 참고

https://en.wikipedia.org/wiki/Scientific_notation

 

Scientific notation - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search Method of writing numbers, especially very large or small ones "E notation" redirects here. For the series of preferred numbers, see E series. For the food additive codes, see E number

en.wikipedia.org

 

 

 

참조 :  https://www.w3schools.com/js/js_numbers.asp

728x90
반응형

댓글