English 中文(简体)
US-ASCII encoding with Odd and Even numbers?
原标题:

I splitted the list of numbers 1-100 to files of 2 bytes. Then, I noticed that each odd number btw 11-99 needs 2 files, ie 4bytes, while each even number btw 11-99 needs 1 file, 2bytes. A file is enough for numbers btw 1-10. You can confirm the finding below.

How can you explain the finding?

What did I do?

  1. save numbers to a file, like in VIM:

    :%!python -c "for i in range(1,100): print i"

    :w! list_0_100

  2. split the file to 2 bytes files with the GNU Split-command in Coreutils:

    $ split -b2 -d list_0_100

Finding: Each odd number btw 11-99 needs only two files, ie 4bytes. In contrast, each even number btw 11-99 needs one file, ie 2bytes:

$ head x*    

==> x07 <==
8

==> x08 <==
9

==> x09 <==
10

==> x10 <==

1
==> x11 <==

1

==> x12 <==
12

==> x13 <==

1
==> x14 <==
3

==> x15 <==
14
==> x16 <==

1
==> x17 <==
5
最佳回答

Each number greater than 9 requires three bytes (one byte for each digit, and one more byte for the new line). Writing _ instead of the new line character (for visibility) you have this:

10_11_12_13_14

After the split:

10 _1 1_ 12 _1 3_ 14

The even numbers happen to lie in one file, but the odd number get split over two files.

问题回答

暂无回答




相关问题
Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Using Java PDFBox library to write Russian PDF

I am using a Java library called PDFBox trying to write text to a PDF. It works perfect for English text, but when i tried to write Russian text inside the PDF the letters appeared so strange. It ...

what is encoding in Ajax?

Generally we are using UTF-8 encoding standard for sending the request for every language. But in some language this encoding standard is not working properly,then in that case we are using ISO-8859-1....

Encoding of window.location.hash

Does window.location.hash contain the encoded or decoded representation of the url part? When I open the same url (http://localhost/something/#%C3%BC where %C3%BCtranslates to ü) in Firefox 3.5 and ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

热门标签