Paul Hartrick dot com保羅Hartrick點通信






The First Program I Ever Wrote第一個程序我曾經撰寫

Feb 7th 2008 2008年2月7日
4 Comments 4評論
261 views 261次
respond回應
trackback引用

Todays post is in response to a good friend of mine always asking about the “Mumbo Jumbo” that I talk about or create during the course of my job.今天的職位是在回答我的好朋友,經常問的是“無意義”,我談論或建立在這一過程中,我的工作。 “Mumbo Jumbo” is actually “Japanese English” for technical talk according to some. “無意義”實際上是“日本英語”的技術討論根據一些。 I have to take you all back to when I was about 14 years old, this is when I purchased my first computer.我要帶你們回在我差不多14歲,這是當我購買了我的第一台計算機。 My first computer wasn't an IBM 486 or 386, or even a 286, my first computer was a Casio PB-100.我的第一台電腦不是IBM的486或386,甚至是286,我的第一台計算機是卡西歐鉛- 100。

Here are the details of my first PC.這細節我的第一台PC。

卡西歐鉛100

The PB-100 represents Casio's step towards “real” pocket computers.在PB - 100是卡西歐的一步,“真正的”掌上電腦。 While its ancestor, the而其祖先的 FX-702P外匯- 702P , was still called “Programmable Calculator”, the PB-100 proudly bears the title “Personal Computer”. ,仍稱為“可編程計算器”,在PB - 100自豪的標題是“個人電腦”。

In its standard version, it is equipped with 1 KB of RAM which results in only 544 bytes for BASIC, which is really limiting.在標準版本,它配備了1 kB的RAM的結果只有544個字節為基本,這實在是限制。 At least, with the memory module OR-1, it can be upgraded to 1568 bytes of user memory, so it begins to make sense that BASIC memory can be subdivided into 10 independent program areas.至少,與內存模塊或- 1,可以升級到1568字節的用戶內存,因此它開始有意義的基本的內存,可分為10個獨立的項目領域。

The main circuits of the PB-100 are basically made up of two chips.主要電路在PB - 100,基本上是由兩個芯片。 Processor logics, ROM, display driver, and keyboard controller are integrated in a single CMOS VLSI chip HD61913, which has an external 4-bit bus.處理器邏輯,光盤,顯示驅動程序和鍵盤控制器被整合在單一CMOS超大規模集成電路芯片HD61913,它有一個外部的4位總線。 The second main component is a HD61914, which is a 8192-bit static RAM organized as 2048 words by 4 bits.第二個主要組件是一個HD61914,這是一個8192位的靜態RAM籌辦2048字由4位。

I had the lot, 1k ram upgrade for a total of 1.5k of ram, thermal printer and tape drive, needless to say it want a very powerful PC, but you would be surprised what could be done with such an underpowered PC, keep reading….我有很多經銷商內存升級總額為1.5k的內存,熱敏打印機和磁帶驅動器,不用說,想要一個非常強大的PC,但你會感到驚訝什麼可以做這樣一個動力不足的PC,請繼續閱讀...。

My first program was written in BASIC, and could calculate the Factorial of any number you like.我的第一個綱領,基本寫的,並可以計算階乘的任何電話號碼你喜歡。 What is Factorial ?因子是什麼? In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n.在數學中,階乘的一個非負整數n,記作N!,是產品的所有的正整數小於或等於n For example, 5!例如,5! = 1 x 2 x 3 x 4 x 5 = 120 and 6! = 1 × 2 × 3 × 4 × 5 = 120和6! = 1 x 2 x 3 x 4 x 5 x 6 = 720. = 1 × 2 × 3 × 4 × 5 × 6 = 720。 As you can imagine the numbers get very large very quickly.正如你能想像得到的數目非常大的非常快。 Most calculators, even today, can only manage 69!, this is the point where the exponent exceeds 99.大多數計算機,即使在今天,只能管理69!,這是點的指數超過99。

So I had a problem I want to solve, what is the factorial of 1 million, 1,000,000!所以,我有一個問題,我想要解決的,什麼是階乘100萬,100萬! logarithms to the rescue.對數營救。 What is a 14 year old boy doing researching logarithms you ask?什麼是14歲的男孩做研究,對數你問? I guess thats a story for another post.我想多數民眾贊成在故事的另一職務。 After a few hours of reading a book, yes a book!( no internet in those days) I was able to establish that product of integers is the sum of their logs.經過幾個小時的讀一本書,是一本書!(沒有互聯網在那些天),我能夠確定該產品的整數的總和他們記錄。

so 1 * 2 * 3 * 4 * 5 … is equal to exp( log(1) + log(2) + log(3)+ log(4) + log(5) )所以1 * 2 * 3 * 4 * 5 ...等於進出口(日誌(1)+日誌(2)+日誌(3)+日誌(4)+日誌(5))

Easy right… yeah right!易權的權利...呀!

So I embarked on my first programming task.因此,我開始了我的第一個編程任務。 I was able to come up with a simple routine that broke the calculation down into small chunks easily handled by any programmable calculator or PC.我能拿出一個簡單的例行公事爆發計算分解成小塊地處理任何可編程計算器或PC。

10 input x 10輸入x
20 for a = 1 to x 20 1 = 1到x
30 b = b + log10(a) 30個B二B + log10(1)
40 next a 40下一頁1
50 c = b – frac(b) 50架C = B組-壓裂(二)
60 d = b – c 60天= B組-葷
70 e = 10 ^ d 70條= 10 ^Ḏ
80 print e , “E+” , c 80列印E類,“E +”,ç

Certainly not the best way to achieve the result by todays standards, and faced with many command restrictions,  still not to bad for a 14 year old boy.當然不是最好的方法來達到以今天的標準,結果,並面臨著許多命令的限制,仍然不壞一14歲男孩。

You can still use this program today, go and download您仍然可以使用該程序的今天,去下載 small basic小基礎 and copy/paste the code and give it a try.並複製/粘貼代碼,並給它一試。 It took more than 12 hours on my PB-100 to calculate 1,000,000!, now it takes about 1 second, I can now appreciate how much performance my laptop has, however my little program still beats the WindowXP calculator at Factorial..花了超過12小時,我鉛- 100來計算1,000,000!,現在需要大約1秒鐘,我現在可以理解的表現多少我的筆記本電腦了,但我的小程序仍在跳動的WindowXP計算器的階乘.. try it and see.嘗試看看。

So what is 1 million Factorial?那麼,什麼是一百萬因子? 1,000,000! 1,000,000! = 8.263930499EXP5565708, that 5.5 million zeros, give or take a few. = 8.263930499EXP5565708,即550.000萬零,給予或需時數。

Now for all the other math heads who read this, I know it is an approximation as I am only using 16 significant digits, and there are more accurate ways to do this, blah blah blah, please remember I was only 14 at the time.現在所有其他數學主管誰讀這一點,我知道這是一個近似值,因為我只用16位有效數字,而且有更準確的方法來做到這一點,等等等等等等,請記得我只是14日的時間。

If you have managed to maintain interest and get to the end of this post, maybe your the type who can impress their friends with some geeky code.如果您有管理,以保持興趣,到最後獲得這個職位,也許你的類型誰能夠打動他們的朋友一些令人討厭的代碼。

To get new stuff automatically subscribe to my要獲得新的東西,我會自動訂閱 RSS feed RSS提要 .
For a more personal insight Follow me on對於更多的個人見解跟我上 Twitter嘰嘰喳喳 .


This post is tagged這個職位是標籤 , , ,

4 Comments 4評論

  1. Gil Hartrick吉爾Hartrick

    Pauly, do you remember where you got the workings from ?…… It was me who brought the Swinburne Uni PC's to a grinding hault in the early eighties with this Factorial Formulae on PUNCH CARDS… YES!保利,你還記得您得到的運作的呢?... ...這是我誰帶來的斯溫伯恩統一電腦的研磨hault八十年代初與此有關的階乘公式穿孔卡片...是的! punch card programming LOL打卡編程LOL

    Reply To This Comment回复此評論

  2. Gil Hartrick吉爾Hartrick

    Remember my Casio Calculator the FX-602P??記住我的卡西歐計算器的FX - 602P?? It computed 1,000,000 factorial in 4 minutes flat, not bad for a meek calculator它在計算1,000,000因子4分鐘持平,而不是壞的溫順計算器

    Reply To This Comment回复此評論

  3. CA Pappas加利福尼亞帕帕斯

    Thanks!謝謝! Believe it or not, I was actually trying to solve 1000000!相信與否,我實際上是試圖解決的1000000! , but, yes, my sci calculator was only good for 69!但,是的,我的科幻計算器只有良好的69! . My windows sci calculator was much better.我的Windows科學計算器就好多了。 It took me up to (10^5)!我花了最多(10 ^ 5)! , but it wouldn't give me (10^6)! ,但它不會給我(10 ^ 6)! .
    I tried some online calculators , but they couldn't even come close to the windows sci calculator.我嘗試一些在線計算器,但他們甚至無法接近窗戶科幻計算器。 For now, and for my purposes, all I needed was that answer.現在,和我的目的,所有我需要的是確切的答案。 I'll search for a calculator later.我要尋找一個計算器以後。 Thank you, again, you have saved me a lot of search time.謝謝你,再次,你救了我很多的搜索時間。 As I am rural, I only have dial-up.由於我的農村,我只有撥號。 Yes, it only feels like it would be faster to just 1 x 2 x 3 x 4 x 5 x ………….with pencil and paper (how many life-times????).是的,它只是喜歡它的要快到1 × 2 × 3 × 4 × 5 × ... ... ... ...。用鉛筆和紙(多少生命時報????). than to search for the answer.而不是尋找答案。 and wait for the snail-speed downloads!!!!並等待蝸牛高速下載!!

    Appreciatively,感激地,
    Chris Aristides Pappas克里斯阿里斯蒂德帕帕斯

    Reply To This Comment回复此評論

    -Paul 保羅 Reply:回复:

    I'm glad you found it useful.我很高興你發現它非常有用。 I'm also glad I'm not the only geek who has an interest in factorial of large numbers.我也很高興,我不是唯一的怪胎誰的權益,在大量的階乘。

    Reply To This Comment回复此評論

Incoming Links接踵而來的鏈接

    Leave a Reply留下回复