• #### 科普

SCIENCE

#### 英语

ENGLISH

#### 科技

TECHNOLOGY

MOVIE

FOOD

#### 励志

INSPIRATIONS

#### 社会

SOCIETY

TRAVEL

#### 动物

ANIMALS

KIDS

#### 卡通

CARTOON

#### 计算机

COMPUTER

#### 心理

PSYCHOLOGY

#### 教育

EDUCATION

#### 手工

HANDCRAFTS

#### 趣闻

MYSTERIES

CAREER

GEEKS

#### 时尚

FASHION

• 精品课
• 公开课
• 欢迎下载我们在各应用市场备受好评的APP

点击下载Android最新版本

点击下载iOS最新版本

扫码下载译学馆APP

#### 《迪哥Java教程》#4 计算机是怎么存储数字的？

How do computers store numbers? - 004

We know computers are great with numbers …usually

But how does a computer store numbers. Some of you might answer we use zeros and ones.

That’s right! But how those zeros and ones organized? Ah ha!

How do we make numbers out of the zeros and ones?

The goals for you for this lesson are to

understand how numbers represented using binary and hexadecimal.

We also want to look at how Java store’s numbers.

This will help us understand the different primitive number types.
Java中可以用来存值的第一种数字类型是计数用的数字
The first type of number we can store in Java are the counting numbers.

These should be the numbers that your most familiar with.
1 2 3 等等
One, two, three etc.

These numbers also include the number zero and negative numbers.

The counting numbers are sometimes called the set integer numbers.

These numbers go on for ever in both positive and negative direction.

On a computer you can’t represent every number no matter how you construct the number.

Eventually you’re gonna run outta space on a computer.

The set of valid numbers that you can use is limited in something we call a Java primitive.

The reason for this is simple.

In a computer a bit is used to store a value of either a zero or a one.

This is the smallest piece of information.

If you want bigger pieces of information, you need to string more bits together.

Your first thought might be, string more ones together and just count them.

So for twelve, that’s a lot of ones just to represent twelve.

Imagine if you wanted a bigger number like 42 or a million.

That plan’s not going to work.

Think about how you represent decimal numbers based on powers of tens.

A decimal number increases by powers of ten for each decimal place.

So 123, equals one times a hundred plus, two times ten, plus three times one.

This is really one times ten to the power
1 × 10² + 2 × 10¹ + 3 × 10º
of two, plus two times ten to the power of one, plus three times ten to the power zero.

Now it might not look like it, but this is the decimal system that you learned when you were a kid.

We do the same thing for binary numbers in a computer.

Like a decimal place we have binary places based on powers of two.

So to represent twelve in binary, we have one times eight plus one
1 × 8 + 1 × 4 + 0 × 2 + 0 × 1
times four, plus zero times two, plus zero times 1.
8 4 2 1都是二的幂次方
Eight, four, two, and one are all powers of two.

So the same way we represent

decimal numbers, you can write twelve as 1100 in binary.

Even binary numbers organized this way can get crazy.

As you can see, we needed four digits to represent twelve.

As numbers get large in binary, we typically switch to a secondary number system called hexadecimal.

This number system is based on powers of sixteen.

And we use letters for the digits beyond 9.

You’re probably wondering why sixteen? It’s not a random number.

Each hexadecimal digit is really a block of four binary digits.

So binary 1010, is hexadecimal A,

or ten in decimal. Pretty cool, huh?

Hey thanks for watching the video!

There’s a quick quiz for this on DeegeU.com if you’d like to gauge how much you learned.

If you like the videos you are seeing,

please let me know by liking the video and hitting the subscribe button to the DeegeU channel on YouTube.

I’d really appreciate that!

If you have concerns or questions please leave them in the comments below or on DeegeU.com.
DeegeU.com的首页有一个投票
There’s a poll on the front page in DeegeU.com,

so you can also let me know what topic is covered next.

Thanks for watching and see you in the next video!