Live is not about money at all. It’s not guaranteed that we will undergo our life with abundant happiness when we own plenty of money to spend for. Money is as a means for us to fulfill our daily needs. We shouldn’t be trapped with our shallow understanding that we merely work for money. As God says in Matthew 8:20: “Foxes have holes and birds of the air have nests, but the Son of Man has no place to lay his head.” By this verse, we are strengthened by His word that we are still able to have a decent life although we have a very limited financial treasure. May God be with us forever. Happy Sunday…..
The motivation of this posting is to discuss some programming technique which enable a function to retrieve value returned by other function in a form of array. To make it clearer, let me take a sorting problem as the example. Assume that we have set the initial value to each array elements. To perform sorting on the array, other function (named as callee) is called and data to be processed are provided by a caller. After a sorting process is over, a callee must return an array with sorted data back to its caller. A global variable is one of ways to exchange data amongs functions. As its name, a global variable has wider scope and lifetime and is accessible by other functions at the same and lower level. The following snippet is a brief implementation on this technique:
/* the declaration of global variable, target_array */
int destination[size];
void sorting(int *src_array, int size) {
/* do sorting here */
/* store the result of data sorting
into a global variable (target_array) */
}
int main() {
/* declare and initialize source before using it */
sorting(source, size);
/* user-defined function to print all array elements */
print_array(destination);
return 0;
}
Aside above technique, we also can use additional function argument as a way for caller and callee function to exchange their data. The implementation of this techinique is as follows:
void sorting(int *dest_array, int *src_array, int size) {
/* do sorting here */
/* store the result of data sorting into which
array is accessible at caller function (e.g. dest_array) */
}
int main() {
/* declare source and destination before using it */
/* initial source as sorting input */
sorting(destination, source, size);
/* user-defined function to print all array elements */
print_array(destination);
return 0;
}
Both techniques described above require a variable which has wider scope (in the first case, the variable is known by all functions while in the later case, the scope of variable is at the same level of the caller function). The next technique is to declare an array inside a callee function and use the characteristic of dynamic memory allocation to preserve memory allocation although the lifetime of the callee function is over. Below is the implementation of this technique:
int *sorting(int *src_array, int size) {
/* declaration of dynamic array */
int *p_inside_sorting;
/* memory allocation of dynamic array */
p_inside_sorting = (int *)malloc(sizeof(int)*size));
/* do sorting here */
/* store the result of data sorting into p_inside_sorting */
return p_inside_sorting;
}
int main() {
/* declare and initialize source before using it */
/* declare a pointer variable as a means for pointing
address reference returned by sorting function */
int *p;
p = sorting(source, size);
/* user-defined function to print all array elements */
print_array(p);
return 0;
}
Since we are allocating lot of memories designated to our dynamic array, we need to free (or de-allocate) the memories if we are going not to use it anymore (e.g. after the termination of the program).
Posted in Programming | Leave a Comment »
While I was working on the 3rd homework of computer arithmetic, suddenly I got bored somehow. Turning on the tv didn’t help as well, because there was no any interesting tv program at the time. Hmmm, then an idea came to my mind, eventhough it wasn’t not a relaxing one, he..he..
It was about divisioning number. Assume that you would like to calculate the result of 5 divided by 7. Of course it’s very easy to solve, by either calculating by hand or using calculator. OK, let’s take the most practical one, with the help of calculator. I did the calculation using Windows calculator, and the result is 0.71428571428571428571428571428571. I discovered that the total number printed behind the dot sign is 32. For most of mathematical purpose, it’s probably more than enough. But then I questioned myselft, is it possible to extend the calculation of decimal number to more than 32 digits?
It didn’t take to much time to conclude that it’s possible to extend the digit number, but it obviously couldn’t be done with the existing calculator. I had to make a small program and it’s not a complicated one. Here I put the snapshot of the code I made in C language:
#include <stdio.h>
#include <string.h>
#define STRING_SIZE 1024
char *udivide(int numerator, int denominator, int counter);
int main ()
{
int inumber, modnumber, counter=0;
printf(“%s”, udivide(17,116,300));
printf(“\n”);
return 0;
}
char *udivide(numerator, denominator, counter)
int numerator;
int denominator;
int counter;
{
static char sresult[STRING_SIZE]=”";
char temp_str[STRING_SIZE]=”";
int local_counter=0, modnumber=numerator;
while (local_counter<counter)
{
numerator = (int) numerator/denominator;
sprintf(temp_str, “%d”, numerator);
if (local_counter==0)
strcat(temp_str, “.”);
if ((numerator = modnumber%denominator)==0)
{
strcat(sresult, temp_str);
break;
}
if (numerator<denominator)
numerator*=10;
modnumber = numerator;
local_counter++;
strcat(sresult, temp_str);
}
return sresult;
}
Depending on the value of counter variable, now I’m able to find the division of any number in longer digit resolution (note: if the digit resolution exceeds the size declared in above code, increase the size of string to a corresponding value). Then I observed that the division of fraction number eventually will produce a periodic number. Below are some examples of the periodic division result:
1 : 116 = 0.0086206896551724137931034482758620689655172413793103448275
86206896551724137931034482758620689655172413793103448275
86206896551724137931034482758620689655172413793103448275
86206896551724137931034482758620689655172413793103448275
86206896551724137931034482758620689655172413793103448275
86206896551724137
22 : 7 = 3.142857142857142857142857142857142857142857142857142857142857142857142857142857
142857142857142857142857142857142857142857142857142857142857142857142857142857
142857142857142857142857142857142857142857142857142857142857142857142857142857
14285714285714285714285714285714285714285714285714285714285714285
I think it’s enough playing with numerator and denominator for today. Maybe if I have another spare time, I will make the function to be recursive, so it will be more elegant than it’s now. I also welcome you to share your recursive version at comment section. Cheers.
Posted in Programming | 4 Comments »
I was very happy when I at last could follow a master program abroad. As graduate from physics engineering, my background academic is really in opposite direction with the knowledge base of the institution where I was working in. Then I tried to think over a win-win solution which could satify all parties involved. After pondering all concerned aspects, then I finally decided to follow computer engineering’s master program for my further academic degree. The main reasons of this decision were computer engineering provides courses and research interest which were very suitable with the core business of my institution and the department also provides the opportunity for student who holds bachelor degree of electrical and physics engineering (like me) to do research the that area.
I realized that the consequence of switching academic track to a new area was to face many new things which I never learnt before. Undoubtfully the consequence is becoming true. At the 6th month following master program at TU Delft, the burden to walk into unknown study area becomes larger. Everyday, when attending a class, the lecturer talked about terminologies and principles which are really new to me and I became more suffered because the lecturer assumed that all those required and supported knowledge have been studied in bachelor (or, if the assumption was considered to be wrong, the lecturer just give students the instruction to read a bunch of prerequisite reading material). Following are few terminologies I must understand in order to pass the courses: carry look ahead, parallel prefix network, parse tree, LALR, finite state automaton, victim cache, cover of cube, etc. (if you’re interested to know what it is, type the keyword on google).
But it doesn’t mean I will quit the fight and walk out the arena. I will do my best to complete the courses and get the degree at the end. Right now, I’m trying to change my mindset to see difficulties as challenges. When I succeed to do so, the remaining journey probably will be more insteresting and I don’t feel tortured,
.
Posted in General | 4 Comments »
The time finally comes. Me and my beloved wife have to live away from each other for more less 9 months. Even though we just married 6 months ago, or you may say, living together as husband and wife is something new for us, but a big missing starts striking my mind, in just a few hours after she went in to the passenger’s waiting room at Schipol airport.
I also felt a different feeling when I came to my room this afternoon. My room seems to be a lot less empty now. I don’t hear anymore romantic words that she usually says when I get in to the room. Not only that, I couldn’t see her very beautiful smile when I was entering the room, and the question about whether I felt hungry or not and when I said I was starved, she woke up from the bed and started to prepare the food for us. After she finished cooking the food, the best moment came when we ate together and in the same time having a little chat about anything we want to talk.
Now I have to be used to be “being alone”. Buying stuff to the market, enjoying light walk, spending spare time, etc. must be gone through without her. I have a very simple pray in my heart that I hope the time will tick faster, so I can meet her sooner and the empty space inhabiting my heart will disappear immediately.
Posted in My Diary | 8 Comments »
Sebenarnya sudah lama saya ingin menulis tentang hal ini, karena saya cukup tergelitik dengan fenomena yang terjadi. Dulu pada saat duduk di SMP atau SMA, kita pernah belajar Fisika dan membahas topik mengenai usaha (work). Dinyatakan bahwa usaha (work) sebanding dengan gaya (force) yang bekerja pada suatu benda, yang mengakibatkan benda tersebut berpindah posisi pada jarak tertentu (distance). Untuk perpindahan posisi dalam gerak lurus tanpa membentuk sudut, maka formula untuk menghitung besarnya usaha dapat dinyatakan sebagai berikut:
usaha (work) = gaya (force) x jarak (distance)
Dari rumus di atas, ada empat permutasi untuk menghitung besarnya usaha yang dihasilkan, yaitu:
- tidak ada gaya yang bekerja pada benda, namun benda mengalami perpindahan posisi (gaya = 0, jarak <> 0)
- tidak ada gaya yang bekerja dan tidak ada perpindahan jarak (gaya = jarak = 0)
- ada gaya yang bekerja pada benda, mengakibatkan adanya perpindahan posisi (gaya <> 0, jarak <> 0)
- ada gaya yang bekerja pada benda, namun benda tidak mengalami perpindahan posisi (gaya <> 0, jarak = 0)
Mari kita ulas satu-satu keempat permutasi di atas. Pada permutasi yang pertama, menurut kesimpulan pribadi saya, sangat tidak mungkin terjadi. Bayangkan jika sebuah buku atau mobil yang berada di sebuah permukaan yang datar, tiba-tiba dapat bergerak dengan sendirinya, berpindah ke posisi yang lain. Kalau seandainya suatu masa kita kebetulan melihat fenomena ini, kemungkinan besar kita akan terlari terbirit-birit dan bulu kuduk sudah berdiri semua, he..he…
Permutasi yang kedua, ketiga, dan keempat merupakan fenomena yang sering terjadi di sekitar kita. Namun untuk permutasi keempat, ada hal yang menarik yang bisa diamati dan bila kita mencoba untuk melihatnya dari sisi yang berbeda, akan menghasilkan hal yang lebih menarik lagi. Perhatikan bahwa di permutasi keempat, besarnya usaha yang dihasilkan adalah nol karena tidak ada perpindahana jarak yang terjadi walaupun gaya diberikan pada benda tersebut. Dengan menggunakan istilah saya sendiri, hal ini saya sebut sebagai “tidak melakukan usaha“. Contoh konkrit mengenai hal ini adalah ketika seseorang berusaha mendorong tembok rumah. Gaya yang diberikan ke tembok rumah tersebut sudah sedemikian besarnya sampai-sampai tenaga orang yang mendorong sudah habis dan banjir keringat, namun tetap saja tembok tidak bergerak sedikit pun. Lebih naas lagi, berdasarkan formula fisika di atas, kita dapat mengatakan bahwa orang tersebut tidak melakukan usaha (dengan istilah lain, tidak berusaha) ketika mendorong tembok tersebut.
Nah sekarang mari kita lihat peristiwa di atas melalui sudut pandang lain, yang lebih bersifat sosial-managerial. Misalkan seseorang berposisi sebagai atasan di suatu institusi, yang memiliki wewenang untuk mengambil keputusan strategis. Pada masa tertentu, dicanangkan program untuk membuat institusi tersebut menjadi lebih baik. Sekian puluh skenario dan program dirumuskan dan dengan memberdayakan potensi insani yang bekerja di perusahaan tersebut, ekspektasi bahwa kualitas institusi dapat lebih meningkat dapat tercapai. Segenap tenaga dan pikiran serta dedikasi dicurahkan demi tercapainya peningkatan kualitas. Namun tanpa disadari, dalam rangkaian kerja yang merupakan bagian dari program peningkatan kualitas institusi, tidak ada satu pun perubahan yang berhasil meningkatkan kualitas institusi. Singkat cerita, di akhir masa pelaksanaan program, setelah melakukan evaluasi tentunya, disimpulkan bahwa kualitas institusi tidak lebih buruk dan sekaligus juga tidak lebih baik dibandingkan kondisi sebelum program peningkatan kualitas dilaksanakan. Dengan kata lain, kualitas institusi tidak mengalami perubahan sama sekali.
Dengan mengandaikan bahwa besarnya gaya adalah total dari peluh keringat, tenaga, pikiran, waktu, dan dedikasi yang disumbangkan oleh orang per orang yang bekerja di dalam perusahaan tersebut dan jarak adalah besarnya peningkatan kualitas institusi (dalam kasus di atas, jarak sama dengan nol), maka dengan meminjam istilah yang telah disebutkan di atas, orang per orang di dalam institusi tersebut tidak melakukan usaha.
Inti dari ilustrasi di atas adalah sebesar apapun tenaga yang kita dedikasikan untuk suatu hal tertentu, tapi pada akhirnya tidak ada hasil yang dicapai, maka di akhir dapat dikatakan bahwa selama ini orang tersebut tidak melakukan usaha. Jadi berhati-hati dan cermatlah untuk menentukan pencapaian, sehingga segala jerih payah yang kita berikan (tenaga, waktu, dedikasi, pikiran) tidak berakhir dengan kesimpulan bahwa kita tidak melakukan usaha sama sekali.
Be rationale, don’t over confidence.
Posted in My Diary | Leave a Comment »
Phuuiiiih, I was just really having a bad experience yesterday. Why I say so? Because all data stored in my laptop accidentally were erased, because of my careless action. OK, let me try to tell you the complete story. A few months ago, my friends told me to use Windows 2003 Server SP1 as operating system, if I want to explore Visual Studio 2005. Then, inspired by that suggestion, I erased my old operating system and installed Windows 2003 Server SP1 inside my laptop. After successfully installing the new OS, I found some disturbing problem caused by incompatible drivers issue. Some of supporting application provided by laptop manufacturer are crashed after being executed. Even the incompatible issue made the applications were unable to be installed properly on the OS. Because of those things, some important features needed to increase laptop performance were disappeared.
Although OS installation consume quite a lot effort and time to spend to, I decided to replace the OS become XP again. I did the OS installation yesterday. At the beginning installation, firstly I put Windows XP installer into CD Rom and boot the laptop through CD. Then, I followed all instructions given along installation as usual, until I realized that something wrong happens during the installation, it didn’t show the list of hard disk partition at all. I tried to do some troubleshooting actions, but nothing can enable me to read the partition. I gathered helpful information from internet to overcome the problem, but still it didn’t work at all. With more less idea remained in my mind, I did a preliminary guess that the problem might have relation with partition manager stored in MBR. By this guessing, I focused the troubleshooting to the way of cleaning MBR from hard disk. On the first try, I used FDISK command provided by XP installer, but it seems to be failed. Then I seek another tool to do such job. From the forum I visited, they suggest to use MbrFix tool that it’s claimed to be more powerful than FDISK. Immediately I downloaded the tool and run it to clean the MBR information. And you know what? The beginning of disaster came. Without criticizing the tool feature, I executed the command as being instructed on the website. It seemed nothing wrong happened then. I repeated the installation process but still it couldn’t read the partition. Hmm, while thinking this weird situation, I decided to put another XP installer into CDRom. And guess what, it could read the partition, but only one. Ups sorry, I forgot to tell you that my hard disk had three partitions on it. Realizing what had happened, I was still in a few minutes, to give enough time for me to think over the stupid thing I had did. I lost all data I have collected since 7 months ago, movies, application, course deliverable, and many useful and important files.
But of course, the show must go on. Instead of tearing this sad story, I continued the installation and listed the remained information inside my mind which is useful to get all files I had lost.
Lesson learnt from this experience is to be aware for everything you will do, even though you are used to do it everyday.
Pondering the lost I got on that day, I categorized yesterday as my unpleasant day,
.
Posted in General | 1 Comment »
Hmmm, it seems so hard to be a dicipline person. Why I say so? When I decided to start a blog for the first time, I do committed to update the content once a week, at least. But what happens then? Day by day, lazy habit always reign on me in a very long time. Of course, sometime there is a will come for conquering that lazy habit, but still the good side always be defeated by the bad one,
. Today I realize that I can’t let it happens all the time on me. I must wake up from the ‘darkside’ of my spirit and strive to walk into the brightside one. Yesterday is the begining proof of what I’m saying now.
On the early yesterday morning, I wrote down my important activities list and get seven activities I must do on that day, e.g. IELST preparation (reading section), Course preparation for STEST, Course preparation for FCBD, Copying SMAN 2 website to my local computer, washing my dirty clothes, cleaning the bedroom, and moving INDOVISION dish to my friend’s house. From those seven things, four were accomplished to be done on that day, one was done on the next day (washing), and two are in progress (course preparation). Hopefully, I can maintain this positive good things, at least until next two months.
Posted in My Diary | Leave a Comment »
Did you know that J. Robert Oppenheimer wasn’t actually trying to create the world’s first atomic bomb? Back in the 1920’s, a young Dr. Oppenheimer was trying to figure out the chemical makeup of the different US states. He began his work on Manhattan Island in New York, mainly because he was living there at the time. Just 5 days into his research he got a call from the US Government granting him the funding that he had asked for, including a full lab out in the Arizona desert (they would ship as much of the island to him that he wanted). This small grant to this largely unknown scientist would change the world forever. Seven years later, Oppenheimer discovered that Manhattan was made of hundreds of atoms. Always the curious one, the good Doctor was determined to get inside, or split, an atom to find out what it was made of. Just 5 years later he got his answer… it was full of explosions. The government was astounded and changed the original Manhattan Project into their new Atomic Bomb testing lab. Dr. Oppenheimer never forgave his curious mind, and even though he continued to head what was left of his dear experiment, he vowed to never try to figure anything out again.
Taken from: http://www.neowin.net/forum/index.php?automodule=blog&blogid=3&showentry=675
Posted in Did you know? | Leave a Comment »
Comment from the blog owner:
Hi again. This is the new category, called Did you know?. In this category, you may find a lot of terms or inventions which might be famous and use widely in recent decade. Many of the articles will be taken from posting written by another person and as appreciation of their intelectual right, the author or at least the page address on where you may find the original one is always provided inside the posting. In this first posting, you could read how “Neapolitan” Ice cream was invented during the Napoleon war. Happy reading. Regard.
————————– End of comment ——————————
Did you know that while facing the long and cold Russian winter, Napoleon invented what is now called “Neapolitan” Ice Cream? Late into his campaign to conquer all of Russia, it is said that all the food that the French troops carried had become frozen from the constant freezing winds. One night after dinner, Napoleon sat down to enjoy a nice German Chocolate cake with a white coconut frosting (a treat he picked up a taste for after taking over that nation) prepared for him by his favorite chef. Unfortunately the ingredients were so cold that instead of a nice warm cake, the dish came out quite frozen. When presented with the frozen dessert, Napoleon was so outraged that he jumped up and stabbed his chef straight through the heart. Still hungry for something sweet (and quite upset at the mess he had made), he called in the chef’s apprentice and demanded a new desert be made, but this time he was in the mood for Vanilla, Chocolate and Strawberry ice cream, all on one plate. And thus, “Neapolitan”, or “Napoleon” (as it was called back then) Ice Cream was invented.
Taken from: http://www.neowin.net/forum/index.php?automodule=blog&blogid=3&showentry=675
Posted in Did you know? | Leave a Comment »