Hamiltonian Algorithm Numbering (HAN)
各アルゴリズムに番号をつけ、コーディング際、使ってるマシーン依存アルゴリズムを明らかにすることで、使用者の使用可能可否を明らかにすること。
ここではコード指定について論議
コード形式の議論
現在は2バイト形式。(4096×16場合)4バイトへの論議進行中。
Code Assignment(コード指定)
sizeof()== (0x0000 ~ 0x3f)
- 0x0000: sizeof(size_t) == 1
- 0x0001: sizeof(size_t) == 2
- 0x0002: sizeof(size_t) == 4
- 0x0003: sizeof(size_t) == 8
- 0x0004: sizeof(size_t) == 12
- 0x0005: sizeof(size_t) == 16
- 0x0006: sizeof(size_t) == 24
- 0x0007: sizeof(size_t) == 32
- 0x0008: sizeof(int) == 1
- 0x0009: sizeof(int) == 2
- 0x000a: sizeof(int) == 4
- 0x000b: sizeof(int) == 8
- 0x000c: sizeof(int) == 12
- 0x000d: sizeof(int) == 16
- 0x000e: sizeof(int) == 24
- 0x000f: sizeof(int) == 32
- 0x0020: sizeof(float) == 1
- 0x0021: sizeof(float) == 2
- 0x0022: sizeof(float) == 4
- 0x0023: sizeof(float) == 8
- 0x0024: sizeof(float) == 12
- 0x0025: sizeof(float) == 16
- 0x0026: sizeof(float) == 24
- 0x0027: sizeof(float) == 32
- 0x0028: sizeof(double) == 1
- 0x0029: sizeof(double) == 2
- 0x002a: sizeof(double) == 4
- 0x002b: sizeof(double) == 8
- 0x002c: sizeof(double) == 12
- 0x002d: sizeof(double) == 16
- 0x002e: sizeof(double) == 24
- 0x002f: sizeof(double) == 32
- 0x0030: sizeof(long double) == 1
- 0x0031: sizeof(long double) == 2
- 0x0032: sizeof(long double) == 4
- 0x0033: sizeof(long double) == 8
- 0x0034: sizeof(long double) == 12
- 0x0035: sizeof(long double) == 16
- 0x0036: sizeof(long double) == 24
- 0x0037: sizeof(long double) == 32
sizeof()>= (0x0040 ~ 0x7f)
- 0x0040: sizeof(size_t) >= 1
- 0x0041: sizeof(size_t) >= 2
- 0x0042: sizeof(size_t) >= 4
- 0x0043: sizeof(size_t) >= 8
- 0x0044: sizeof(size_t) >= 12
- 0x0045: sizeof(size_t) >= 16
- 0x0046: sizeof(size_t) >= 24
- 0x0047: sizeof(size_t) >= 32
- 0x0048: sizeof(int) >= 1
- 0x0049: sizeof(int) >= 2
- 0x004a: sizeof(int) >= 4
- 0x004b: sizeof(int) >= 8
- 0x004c: sizeof(int) >= 12
- 0x004d: sizeof(int) >= 16
- 0x004e: sizeof(int) >= 24
- 0x004f: sizeof(int) >= 32
sizeof()<= (0x0080 ~ 0x00bf)
Endian check & bitwise algorithms (0x00c0 ~ 0x00ff)
マシーンのアルゴリズム使用可否テストプログラム作成
実行ファイルが大きくなろうとも、メモリーを多く使わないこと。検査量が多いため、関数にした場合、関数の数が半端ない。
Code Example
<test.h>
#include <iostream>
#include <string>
bool printonly_sw = false;
void printonly(bool sw = true){
printonly_sw = sw;
return;
}
std::string TEST_TEXT(unsigned short cnt){
if (cnt == 0x0000) return "sizeof(int) == 1";
if (cnt == 0x0001) return "sizeof(int) == 2";
if (cnt == 0x0002) return "sizeof(int) == 4";
......(omission)......
if (cnt == 0x002e) return "sizeof(size_t) >= 24";
if (cnt == 0x002f) return "sizeof(size_t) >= 32";
return "TEXT unavailable";
}
void print(unsigned short cnt, bool available){
if (available)
std::cout << "Algorithm " << cnt << ": " << TEST_TEXT(cnt) << " >> " << "True" << std::endl;
else if (!::printonly_sw)
std::cout << "Algorithm " << cnt << ": " << TEST_TEXT(cnt) << " >> " << "False" << std::endl;
return;
}
<test.cpp>
#include "test.h"
int main(void){
printonly(true);
//0x0000
print(0x0000, sizeof(int) == 1);
//0x0001
print(0x0001, sizeof(int) == 2);
//0x0002
print(0x0002, sizeof(int) == 4);
//0x0003
print(0x0003, sizeof(int) == 8);
......(omission)......
//0x001e
print(0x001e, sizeof(long double) == 24);
//0x001f
print(0x001f, sizeof(long double) == 32);
return 0;
}
最終更新:2009年06月07日 17:25