| |

VerySource

 Forgot password?
 Register
Search
View: 877|Reply: 9

Confusion !!!!! The difference between characters in memory and hard disk storage.

[Copy link]

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-29 23:20:01
| Show all posts |Read mode
I don't quite understand the following sentence:
"When reading a text file into memory, you need to convert the ASCII code to binary code, and when writing the file to the disk in text mode, you also need to convert the binary code to ASCII code, so reading and writing the text file takes more Conversion time. There is no such conversion for reading and writing binary files. "
   May I have the following understanding? For example, the value of the character "A" is 41, and there is only one storage format in memory, which is binary "101001", and if it is stored on the hard disk, there are two ways: It is 7 bytes, which respectively store the ASCII code value of the characters 1,0,1,0,0,1; if it is a binary file, it is the binary value "100001" of the decimal value 41, using only one byte.
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-5 23:30:01
| Show all posts
Where did you read this?
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-3-6 14:15:01
| Show all posts
I saw it on a webpage, but I remember it appeared in Tan Haoqiang's C language book
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-7 08:00:01
| Show all posts
8bit (bit) = 1Byte (byte)
1024Byte (byte) = 1KB
1024KB = 1MB
1024MB = 1GB
1024GB = 1TB

First you study the unit problem
Computers are indeed stored in bytes
For example, if you say a, you want to form a binary string, which is 0101001.
All are in groups of 8. You can look at the asc table
Don't confuse bits with bytes.
The so-called binary application is the “switch” state at the physical level. A minimum unit of disk can only represent 2 states
So we call it Yes No // On Off // 1 0 // Yes No
This is the smallest unit. It is a bit. So a group of 8 bits is a byte.
That's the meaning. . . .
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-7 15:00:01
| Show all posts
Let me tell you the principle of storage media.

How does the CD-ROM work? ?

If the empty disc is a flat surface,
So writing numbers in it is pitting with a laser. . . .
Where there are pits is 1 (Of course, it can also be defined as 0, just to describe the state)
Then the disc on which the data was written is a pitted surface
Then read these pits when reading the disk. . . .
How the pits are made is a chemical material. If you are interested, look for it online

The magnetic disk is in the suspended state of magnetic powder.
For example, tape 5 inch disk 3.5 inch hard disk. . . .
Specifically, each "pit" or every bump is a BIT
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-3-7 18:30:01
| Show all posts
gameyum: I understand what you said, but what I asked was the difference between the character a stored in memory and in a disk file.
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-7 20:45:01
| Show all posts
The current computer, whether it is in the hard disk or the memory, the data is stored in binary mode, so the code of the character "a" is the same in memory and hard disk. If you only deal with ASCII, you don't need much conversion at all. It's just that reading a file in text mode will handle things like carriage returns and line feeds.
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-3-8 13:45:01
| Show all posts
According to the above statement, the character A uses a byte to store the binary value 101001 in memory, which is 41 in decimal. There are two forms in the hard disk file: the binary file format, which is the same as the storage in memory. But what is stored in text format? Is it six bytes to store this "101001" binary character form?
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-3-8 18:00:01
| Show all posts
Thank youKTPOPOfor your help! !! What I don't understand is that according to your statement, the character a has only one form stored on the hard disk, right? That is, it is not divided into text format or binary format.
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-3-12 13:30:01
| Show all posts
No difference for the letters, the difference is the value
Int i
i = 32767
Then save i in text form, which is the five bytes 0x33 0x32 0x37 0x36 0x37
2 bytes if saved in binary (16-bit system)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list