What Is 0 ^ 0?

Quick questions:

What is 2 ^ 3? 8

What is 10 ^ 2? 100

What is 912873683428920348791239817231928370 ^ (200 – (40 * 5)) ? 1

Very good. It is an easy test, right? Yes indeed. OK let’s try another question: what is 0 ^ 0?

I repeat: what is 0 ^ 0?

..

..

Give up? OK. This time I’ll answer this question programmatically, not mathematically (there are several approach used to tackle this problems: limit, set theory, etc). Here’s the X86 assembly to outline the idea:


format PE console 4.0

include 'win32a.inc'

entry start

section '.data' readable executable
num1 dd 0
num2 dd 0
fmt db "%d",0

section '.code' code readable executable
start:
mov ecx, [num1]
mov eax, [num2]
mov ebx, ecx

process:
cmp eax, 1
jg multiply
je done

multiply:
imul ecx, ebx
dec eax
jmp process

done:
invoke printf, fmt, ecx
invoke ExitProcess, 0

section '.idata' import data readable writable
library kernel32,'kernel32.dll', msvcrt, 'msvcrt.dll'
import kernel32, ExitProcess, 'ExitProcess'
import msvcrt, printf, 'printf'

The output is, surprisingly (or not surprisingly) 0.

I expect careful readers to complain that I’m cheating, since the output of the code will always be 0.

No, I’m not cheating. May I suggest you to play with the code yourself? Probably you’ll be even more surprised :mrgreen:

Advertisements

Inside MP3

If you are curious about the structure of MP3 file, please take a look at this:

MP3 File Structure Description

MP3 file is divided into a small blocks – frames. Each frame has constant time length 0.026 sec.
But size of one frame (in Bytes) varies according to bitrate. Eg. for 128kbps it is (normally) 417 Bytes and for 192kbps 626 Bytes.

The first 4 Bytes of each frame is frame header and the rest is audio data…

I have a strong felling that I’ll mess with this soon.

Ouch.

Two Small Comments About Linux vs Windows

Just read this blog post. I’d like to give comments on these 2 things.

Alangkah bagusnya jika kita menggunakan OSS secara menyeluruh………

……… Oke, back to topic. Intinya, kita tidak bisa menggunakan salah satu saja dari 2 OS ini.

For readers who don’t understand Indonesian, here’s the naive translation:

If would be nice if we use OSS exclusively

……… OK, back to topic. The bottom line is we cannot use  only 1 of those OSes.

As you can see, things are not all  rosy. We wish we could use only OSS. But in reality, we also use non OSS. Idealism which is not strong enough, yes?

And next:

Niat make Linux, Tapi kalo LINUX BISA MAEN BATTLEFIELD 3 dan GAME Cool lainnya.Thanks…

Aha… saya bisa menebak anda…
kan bisa pake dual boot mas… Linux dan Windus dalam satu kompi…

Naive translation:

I want to use Linux. Can it play Battle Field 3 and the other cool games? Thanks…

Aha, I can read your mind. Use dual boot: Linux and Windows in 1 desktop.

This is like saying “Damn, Linux desktops suck for gaming. We can’t play cool games on them. Let’s use Windows”. Which is unfortunately true. Most cool games still are targeted for Windows and gaming consoles. Sure you can use Wine or anything similar, but the rate of success is not guaranteed to be 100%. Do it at your own risk.

Yes, now there is Steam. Kudos for the developer for giving attention to Linux. But still, we need MOAR game developers/publishers to contribute. Square Enix, Rockstar Games, EA Games etc etc, when will you join this movement? :mrgreen:

 

Thunderbird Memory Usage

Thunderbird is my favorite email & Usenet client. Use it on both my Windows & Linux system. It works great.

Until recently, I found a memory usage problem on Windows.

tbmem

Tunderbird took almost 600 MB of RAM (my notebook has 2 Gigs). And not surprisingly, every time I run it, my laptop become quite slow for a while. Makes me wonder what the real cause is. Let’s list a few possibilities.

  1. Too many email accounts? I only have 3 mails on it. Two for personal usage and one for office usage. One of my personal mail has quite big traffic ocassionaly (due to mailing lists)
  2. Too many add-ons? The add-ons I’m using are Display Mail User Agent, EditEmailSubject, Enigmail, Lightning, MinimzeToTray revivced, and Thundebird Conversations. AFAIR, only the last one affect the responsiveness, a bit.
  3. Antivirus? Is it possible that the inboxes are being scanned.

Until I could solve this problem, it’s better to look for alternatives. Outlook or The Bat!, maybe?

 

 

Always Use error_reporting(E_ALL)

PHP

I’m mostly a Java guy, who very rarely use PHP. Recently, I just wrote some web services (which is obviously ini PHP) for the project I’m working on. One of them didn’t work as expected, and I could not figure it out (must have been sleepy!!)

function XOR_encrypt($message, $key){
$ml = strlen($message);
$kl = strlen($key);
$newmsg = "";

for ($i = 0; $i < $ml; $i++){
$newmsg = $newmsg . ($msg[$i] ^ $key[$i % $kl]);
}

return base64_encode($newmsg);
}

I spent 2 hours looking at the code scratching my head, wondering why on earth it gave the wrong result. Of course, aware readers will notice the error instantly: the msg variable hasn’t been declared before. And PHP happily ran the code without giving warnings.

Finally, a friend suggested to use error_reporting. I did, and reloaded the code. Then I saw a bunch of errors.

Well, what a waste of 2 hours :mrgreen:

 

Kernel panic

The last time I upgrade my Arch Linux system was about 2 months ago. So yesterday, I did a “pacman -Syu”, and got about 1.6 GB of updates. Awesome, let’s do it. So I did, and then went to sleep.

After I woke up this morning, I checked my laptop. Yikes, the update process was failed.

error: failed to commit transaction (conflicting files)
glibc: /lib64 exists in filesystem

So I, foolishly repeated the update process, by using additional parameters: “pacman -Syu –force”. Waited for a while, and it was done!

Let’s reboot. Uh oh, something was wrong, because it didn’t reboot. So I turned of the laptop manually and turned it on again.

Ah wonderful. I got another kernel panic 😡

Let’s see how easy I can fix this problem…