Weil Jimmer's BlogWeil Jimmer's Blog


關於小數的進位法 10進位轉2進位、2進位轉10進位。
No Comments

Published:
Updated:2017-05-24 17:03:16

這個問題真的很難處理很難處理!然而網路上也是Google 很久才有的資料。

好吧進入正題。

首先,大家應該都知道,進位算法就是取餘數,但是小數的算法卻是 乘 起來,取整。

Example:

*****0.625 轉 2進位制:

第1式:0.625 × 2 = 1.250 =======>1

第2式:0.250 × 2 = 0.500 =======>0

第3式:0.500 × 2 = 1.000 =======>1

答案是:101

*****0.125 轉 2進位制:

第1式:0.125 × 2 = 0.250 =======>0

第2式:0.250 × 2 = 0.500 =======>0

第3式:0.500 × 2 = 1.000 =======>1

答案是:001

*****0.3 轉 2進位制:

第1式:0.3 × 2 = 0.6 =======>0

第2式:0.6 × 2 = 1.2 =======>1

第3式:0.2 × 2 = 0.4 =======>0

第4式:0.4 × 2 = 0.8 =======>0

第5式:0.8 × 2 = 1.6 =======>1

第5式 偵測到重複字串,造成循環無限小數。

由第2式開始循環字串。

答案是:01001

這樣大概就夠了,這是 10 轉 2 的方式,其他就以此類推。

但是網路上很少有提到!轉回來。只有轉過去。

123.45 = 1 × 102 + 2 × 101 + 3 × 100 + 4 × 10-1 + 5 × 10-2

所以,小數點後,如果是2進位,則是2-1、2-2、2-3 ‧‧‧‧‧‧‧以此類推。

真是難處理,尤其是無限小數的轉換。

所以,我原本也想做一個很棒的程式,但看樣子,我也許得放棄了。

因為有夠麻煩!我目前的程式因為 算的精度太高了,所以無法處理無限小數的問題。

我大概 應該還會繼續完成的樣子,只是需要時間思考。


This entry was posted in Functions By Weil Jimmer.

About Weil Jimmer

avatar

Hi! Everyone! My name is Weil Jimmer. This is my personal blog. I'm a webmaster of this site. I hope the site will be popular. Now, Let's go! Enjoy gaining more knowledge.
More Details About Me : https://weils.net/profile.php

Leave a Reply

Name*:

Email*:

Website:

Privacy:   

Comment*:

Visitor Count

pop
nonenonenone

Note

歡迎前來本站。

Search

Republic Of China
Privacy is your right and ability to be yourself and express yourself without the fear that someone is looking over your shoulder and that you might be punished for being yourself, whatever that may be.

It is quality rather than quantity that matters.

I WANT Internet Freedom.

Reality made most of people lost their childishness.

Justice,Freedom,Knowledge.

Support/Donate

This site also need a little money to maintain operations, not entirely without any cost in the Internet. Your donations will be the best support and power of the site.
MethodBitcoin Address
bitcoin1NRMVGGpm2T1pmeejisLSEhCXfCefEW9V4
paypal

The Lie We Live

youtube

The Questions We Never Ask

youtube

Support The Zeitgeist Movement

The Zeitgeist Movement

Man

youtube

In The Fall

youtube

Facebook is EATING the Internet

Facebook

Recent Comments

Burhan Uddin on 推薦 "羅馬" 這部影集

sickcatail on STEAM免費序號

包包 on STEAM免費序號

問問題 on 最棒的手機通訊軟體 Telegram

unocme on STEAM免費序號

Categories

Announcement (3)

Bash (2)

C (1)

C# (4)

C++ (1)

Experience (38)

Flash (2)

Free (10)

Functions (35)

Games (13)

General (44)

HTML (7)

Java (12)

JS (7)

Mood (23)

Note (24)

Office (1)

PHP (9)

Privacy (3)

Product (9)

Python (4)

Software (8)

The Internet (15)

Tools (12)

VB.NET (8)

WebHosting (7)

Wi-Fi (5)

XML (4)