2010年2月4日 星期四

Big endian, Little endian

big endian 與 little endian 指的是位元組在記憶體裡面的排列順序(詳細定義更複雜,這裡為方便起見以此為例)
  • big endian:較高的位元組在位址的較後位置,舉例來說
    long a = 0x12345678,這樣子的資料在記憶體裡面的排列順序為 0x12 0x34 0x56 0x78
    參考wiki的圖如下

    File:Big-Endian.svg

  • little endian:較高的位元組在位址的較前位置,繼續前面的例子
    long a = 0x12345678,這樣子的資料在記憶體裡面的排列順序為 0x78 0x56 0x34 0x12
    參考wiki的圖如下

    File:Little-Endian.svg

2010年2月3日 星期三

程式設計上的兩種Stub

  1. 不包含任何邏輯,純粹只是一個空的function,這種function叫做stub function

    public void int sum(int a, int b) {
        //do not calculate but return a constant number
        return 0;
    }

  2. 在分散式系統中,處理的function在remote端,而在local端設計一個function,接收local端的參數,然後再送交remote端處理。

    public void int sum(int a, int b) {
        //call remote function
        mWebRMI.sum(a, b);
    }

     
依照wiki的定義:

A stub in distributed computing is a piece of code used for converting parameters passed during a Remote Procedure Call (RPC).