Skip to Content
러닝 자바스크립트: ES6로 제대로 입문하는 모던 자바스크립트 웹 개발
book

러닝 자바스크립트: ES6로 제대로 입문하는 모던 자바스크립트 웹 개발

by 한선용, 이선 브라운
July 2017
Beginner to intermediate
464 pages
10h 38m
Korean
Hanbit Media, Inc.
Content preview from 러닝 자바스크립트: ES6로 제대로 입문하는 모던 자바스크립트 웹 개발
332
러닝 자바스크립트
16.1
숫자 형식
숫자를 다루다 보면 형식을 맞춰야 할 일이 많습니다. 즉,
2
.
0093
2
.
1
이라고 표시하거나,
1949032
1
,
949
,
032
로 표시하는 것입니다.
1
자바스크립트는 다양한 숫자 형식을 지원하지는 못합니다.
10
진수 형식, 고정 소수점 형식, 지
수 형식이 몇 가지 있는 정도입니다. 숫자를
2
진수,
8
진수,
16
진수로 나타낼 수도 있습니다.
자바스크립트의 숫자 형식 메서드는 모두 숫자가 아니라 문자열을 반환합니다. 해당 형식에 필
요한 각종 기호를 온전히 표현하려면 반드시 문자열이어야 하기 때문입니다 (물론 이런 문자
열은 쉽게 숫자로 바꿀 수 있습니다 ). 따라서 숫자 형식을 바꾸는 건 실제로 표시하기 직전에
해야 합니다. 숫자를 저장하거나 계산할 때는 따로 형식을 지정하지 않은 숫자 타입이어야 합
니다.
16.1.1
고정 소수점
소수점 뒤 자릿수를 지정하는 형식을 원한다면
toFixed
()
를 사용합니다.
const
x
=
19
.
51
;
x
.
toFixed
(
3
); // "
19
.
510
"
x
.
toFixed
(
2
); // "
19
.
51
"
x
.
toFixed
(
1
); // "
19
.
5
"
x
.
toFixed
(
0
); // "
20
"
이 숫자는 버림
truncation
이 아니라 반올림
round
입니다.
16.1.2
지수 표기법
지수 표기법이 필요할 때는
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

웹 애플리케이션 보안: 정찰, 공격, 방어 세 단계로 배우는 웹 애플리케이션 보안의 모든 것

웹 애플리케이션 보안: 정찰, 공격, 방어 세 단계로 배우는 웹 애플리케이션 보안의 모든 것

최용, 앤드루 호프먼

Publisher Resources

ISBN: 9788968483387