vak: (Default)
[personal profile] vak
[personal profile] spamsink предложил запустить на Крэе известный тест enquire.c Стивена Пембертона, из статьи "Everything you wanted to know about your C compiler, but didn't know who to ask". Пришлось побороться некоторое время с Си компилятором. Как выяснилось, он не кушает вещественные литералы, потому что отсутствует некая библиотека. После замены вещественных литералов целочисленными тест успешно скомпилировался. Вот его результат:
Produced by enquire version 5.1a, CWI, Amsterdam
   http://www.cwi.nl/~steven/enquire.html
Compiler claims to be ANSI C level 2

Compiler names are at least 64 chars long
Preprocessor names are at least 64 long

SIZES
char = 8 bits, unsigned
short=64 int=64 long=64 float=64 double=64 bits
long double=128 bits
char*=64 bits
int* =64 bits
func*=64 bits
Type size_t is unsigned short/int
Type wchar_t is signed short/int

ALIGNMENTS
char=1 short=8 int=8 long=8
float=8 double=8
long double=8
char*=8 int*=8 func*=8

CHARACTER ORDER
short: ????EFGH
int:   ABCDEFGH
long:  ABCDEFGH

PROPERTIES OF POINTERS
Char and int pointer formats seem identical
Char and function pointer formats are different
Strings are shared
Type ptrdiff_t is signed short/int
BEWARE! Dereferencing NULL doesn't cause a trap

PROPERTIES OF INTEGRAL TYPES
Overflow of a short does not generate a trap
Maximum short = 2147483647 (= 2**31-1)
Minimum short = -2147483648
Overflow of an int does not generate a trap
Maximum int = 351843720888317 (= 2**47-1)
Minimum int = -351843720888318
Overflow of a long does not generate a trap
Maximum long = 9223372036854775807 (= 2**63-1)
Minimum long = -9223372036854775808
Maximum unsigned short = 4294967295
Maximum unsigned int = 18446744073709551615
Maximum unsigned long = 18446744073709551615

PROMOTIONS
unsigned short promotes to signed short/int
long+unsigned gives unsigned short/int

PROPERTIES OF FLOAT
Base = 2
Significant base digits = 48 (= at least 14 decimal digits)
Arithmetic rounds towards zero (i.e. it chops)
Smallest x such that 1.0-base**x != 1.0 = -47
Smallest x such that 1.0-x != 1.0 = 7.105427357601002e-15
Smallest x such that 1.0+base**x != 1.0 = -47
Smallest x such that 1.0+x != 1.0 = 7.105427357601002e-15
(Above number + 1.0) - 1.0 = 7.105427357601002e-15
Although arithmetic chops, it uses guard digits
Number of bits used for exponent = 14
Minimum normalised exponent = -8193
Minimum normalised positive number = 0.000000000000000e-01

*** WARNING: Possibly bad output from printf above
    expected value around 4.584009668887118e-2467, bit pattern:
    00100000 00000000 10000000 00000000 00000000 00000000 00000000 00000000
    sscanf gave           0.000000000000000e+00, bit pattern:
    00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    difference= 0.000000000000000e-01

The smallest numbers are normalised
Maximum exponent = 16383
Maximum number = *********************

*** WARNING: Possibly bad output from printf above
    expected value around 0.000000000000000e1, bit pattern:
    01111111 11111111 11111111 11111111 11111111 11111111 11111111 11111110
    sscanf gave           0.000000000000000e-01, bit pattern:
    00000000 00000000 00000000 00000000 00000000 00000000 11011011 01011110
    difference= *********************

Overflow doesn't seem to generate a trap
Divide by zero doesn't generate a trap
Only 62 of the 64 bits of a float are actually used
It doesn't look like IEEE format

PROPERTIES OF DOUBLE
Base = 2
Significant base digits = 48 (= at least 14 decimal digits)
Arithmetic rounds towards zero (i.e. it chops)
Smallest x such that 1.0-base**x != 1.0 = -47
Smallest x such that 1.0-x != 1.0 = 7.105427357601002e-15
Smallest x such that 1.0+base**x != 1.0 = -47
Smallest x such that 1.0+x != 1.0 = 7.105427357601002e-15
(Above number + 1.0) - 1.0 = 7.105427357601002e-15
Although arithmetic chops, it uses guard digits
Number of bits used for exponent = 14
Minimum normalised exponent = -8193
Minimum normalised positive number = 0.000000000000000e-01

*** WARNING: Possibly bad output from printf above
    expected value around 4.584009668887118e-2467, bit pattern:
    00100000 00000000 10000000 00000000 00000000 00000000 00000000 00000000
    sscanf gave           0.000000000000000e+00, bit pattern:
    00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    difference= 0.000000000000000e-01

The smallest numbers are normalised
Maximum exponent = 16383
Maximum number = *********************

*** WARNING: Possibly bad output from printf above
    expected value around 0.000000000000000e1, bit pattern:
    01111111 11111111 11111111 11111111 11111111 11111111 11111111 11111110
    sscanf gave           0.000000000000000e-01, bit pattern:
    00000000 00000000 00000000 00000000 00000000 00000000 11011011 01011110
    difference= *********************

Overflow doesn't seem to generate a trap
Divide by zero doesn't generate a trap
Only 62 of the 64 bits of a double are actually used
It doesn't look like IEEE format

PROPERTIES OF LONG DOUBLE
Base = 2
Significant base digits = 96 (= at least 28 decimal digits)
Arithmetic rounds towards zero (i.e. it chops)
Smallest x such that 1.0-base**x != 1.0 = -95
Smallest x such that 1.0-x != 1.0 = 2.52435489670723777731753140890e-29
Smallest x such that 1.0+base**x != 1.0 = -95
Smallest x such that 1.0+x != 1.0 = 2.52435489670723777731753140890e-29
(Above number + 1.0) - 1.0 = 2.52435489670723777731753140890e-29
Although arithmetic chops, it uses guard digits
Number of bits used for exponent = 14
Minimum normalised exponent = -8193
Minimum normalised positive number = 0.00000000000000000000000000000e-01

*** WARNING: Possibly bad output from printf above
    expected value around 4.58400966888711791405353099960e-2467, bit pattern:
    00100000 00000000 10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    sscanf gave           0.00000000000000000000000000000e+00, bit pattern:
    00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    difference= 0.00000000000000000000000000000e-01

The smallest numbers are normalised
Maximum exponent = 8191
Maximum number = ***********************************

*** WARNING: Possibly bad output from printf above
    expected value around 5.45374067809707964731492127240e2465, bit pattern:
    01011111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 00000000 00000000 11111111 11111111 11111111 11111111 11111111 11111110
    sscanf gave           0.00000000000000000000000000000e+00, bit pattern:
    00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    difference= ***********************************

Overflow doesn't seem to generate a trap
Divide by zero doesn't generate a trap
Only 110 of the 128 bits of a long double are actually used
It doesn't look like IEEE format

Float expressions are evaluated in double precision
Double expressions are evaluated in double precision
Long double expressions are evaluated in long double precision
Дальше тест зависает. Как я понимаю, он пытается определить максимальный размер памяти, доступный для malloc(). Но ядро Unicos его на этом подвешивает.

Date: 2024-02-07 05:58 (UTC)
spamsink: (Default)
From: [personal profile] spamsink
Интересный у них там формат плавающей точки.

И как scanf с плавающей точкой работает без той библиотеки, неясно. Или в другом каком месте находит?

Размер памяти - это примерно последнее, что он делает? Если нет, то можно же и закомментировать.

Date: 2024-02-07 06:33 (UTC)
spamsink: (Default)
From: [personal profile] spamsink
Нарисовано, что все биты используются, а оно говорит, что только 62.
???

Date: 2024-02-07 11:49 (UTC)
juan_gandhi: (Default)
From: [personal profile] juan_gandhi

Какая фундаментальная вещь!