| sign.c | 
| /*
 * sign.c --- MSB が符号を表わすことの確認
 */
#include <stdio.h>
#include <math.h>
#include "bdsd.h"
int main()
{
  double x;
  bdsd s;
  x = 1; double_to_bin_digits(x, s);
  printf("x=%g\n", x); print_bdsd(s); printf("\n");
  x *= -1; double_to_bin_digits(x, s);
  printf("x=%g\n", x); print_bdsd(s); printf("\n");
  x = 4.0 * atan(1.0); double_to_bin_digits(x, s);
  printf("x=%g\n", x); print_bdsd(s); printf("\n");
  x *= -1; double_to_bin_digits(x, s);
  printf("x=%g\n", x); print_bdsd(s); printf("\n");
  x = 0; double_to_bin_digits(x, s);
  printf("x=%g\n", x); print_bdsd(s); printf("\n");
  x *= -1; double_to_bin_digits(x, s);
  printf("x=%g\n", x); print_bdsd(s); printf("\n");
  return 0;
}
 | 
| sign 実行結果 | 
| takebe% ./sign x=1 0 01111111111 0000000000000000000000000000000000000000000000000000 x=-1 1 01111111111 0000000000000000000000000000000000000000000000000000 x=3.14159 0 10000000000 1001001000011111101101010100010001000010110100011000 x=-3.14159 1 10000000000 1001001000011111101101010100010001000010110100011000 x=0 0 00000000000 0000000000000000000000000000000000000000000000000000 x=0 1 00000000000 0000000000000000000000000000000000000000000000000000 takebe% | 
先頭のビットが符号を表わしていること、
また確かに  にも二種類あることが分かる。
 にも二種類あることが分かる。
桂田 祐史