The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



Индекс форумов
Составление сообщения

Исходное сообщение
"Релиз ядра Linux 3.4. Обзор новшеств"
Отправлено pavlinux, 21-Май-12 17:03 
> Пруф: http://www.gnuplanet.ru/main/topic.php?topic_id=3246&rnd=753... (в конце)

Это не пруф, это такое же быдлокодеро как и тут.
--
Intel® 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes:1, 2A, 2B, 2C, 3A, 3B, and 3C
http://www.intel.com/content/www/us/en/processors/architectu...


4.1
FUNDAMENTAL DATA TYPES
The fundamental data types are bytes, words, doublewords, quadwords, and double
quadwords (see Figure 4-1). A byte is eight bits, a word is 2 bytes (16 bits), a
doubleword is 4 bytes (32 bits), a quadword is 8 bytes (64 bits), and a double quad-
word is 16 bytes (128 bits). A subset of the IA-32 architecture instructions operates
on these fundamental data types without any additional operand typing.

The quadword data type was introduced into the IA-32 architecture in the Intel486
processor; the double quadword data type was introduced in the Pentium III
processor with the SSE extensions.
Figure 4-2 shows the byte order of each of the fundamental data types when refer-
enced as operands in memory. The low byte (bits 0 through 7) of each data type
occupies the lowest address in memory and that address is also the address of the
operand.

4.2
NUMERIC DATA TYPES
Although bytes, words, and doublewords are fundamental data types, some instruc-
tions support additional interpretations of these data types to allow operations to be
performed on numeric data types (signed and unsigned integers, and floating-point
numbers). Single-precision (32-bit ) floating-point and double-precision (64-bit)
floating-point data types are supported across all generations of SSE extensions and
Intel AVX extensions. Half-precision (16-bit) floating-point data type is supported
only with F16C extensions (VCVTPH2PS, VCVTPS2PH).

4.2.1 Integers

The Intel 64 and IA-32 architectures define two types of integers: unsigned and
signed. Unsigned integers are ordinary binary values ranging from 0 to the maximum
positive number that can be encoded in the selected operand size. Signed integers
are two’s complement binary values that can be used to represent both positive and
negative integer values.
Some integer instructions (such as the ADD, SUB, PADDB, and PSUBB instructions)
operate on either unsigned or signed integer operands. Other integer instructions
(such as IMUL, MUL, IDIV, DIV, FIADD, and FISUB) operate on only one integer type.
The following sections describe the encodings and ranges of the two types of
integers.

4.2.1.1 Unsigned Integers

Unsigned integers are unsigned binary numbers contained in a byte, word, double-
word, and quadword. Their values range from 0 to 255 for an unsigned byte integer,
from 0 to 65,535 for an unsigned word integer, from 0 to 232 – 1 for an unsigned
doubleword integer, and from 0 to 264 – 1 for an unsigned quadword integer.
Unsigned integers are sometimes referred to as ordinals.

4.2.1.2 Signed Integers

Signed integers are signed binary numbers held in a byte, word, doubleword, or
quadword. All operations on signed integers assume a two's complement representa-
tion. The sign bit is located in bit 7 in a byte integer, bit 15 in a word integer,
bit 31 in a doubleword integer, and bit 63 in a quadword integer he sign bit is set
for negative integers and cleared for positive integers and zero.
  Integer values range from –128 to +127 for a byte integer, from –32,768 to +32,767
for a word integer, from –231 to +231 – 1 for a doubleword integer, and from –263 to
+263 – 1 for a quadword integer.
When storing integer values in memory, word integers are stored in 2 consecutive
bytes; doubleword integers are stored in 4 consecutive bytes; and quadword inte-
gers are stored in 8 consecutive bytes.
The integer indefinite is a special value that is sometimes returned by the x87 FPU
when operating on integer values. For more information, see Section 8.2.1, “Indefi-
nites.”

4.3
POINTER DATA TYPES
Pointers are addresses of locations in memory.
In non-64-bit modes, the architecture defines two types of pointers: a near pointer
and a far pointer. A near pointer is a 32-bit (or 16-bit) offset (also called an effec-
tive address) within a segment. Near pointers are used for all memory references in
a flat memory model or for references in a segmented model where the identity of
the segment being accessed is implied.
A far pointer is a logical address, consisting of a 16-bit segment selector and a 32-bit
(or 16-bit) offset. Far pointers are used for memory references in a segmented
memory model where the identity of a segment being accessed must be specified
explicitly. Near and far pointers with 32-bit offsets are shown in Figure 4-4.

4.3.1 Pointer Data Types in 64-Bit Mode

In 64-bit mode (a sub-mode of IA-32e mode), a near pointer is 64 bits. This
equates to an effective address. Far pointers in 64-bit mode can be one of three
forms:

• 16-bit segment selector, 16-bit offset if the operand size is 32 bits
• 16-bit segment selector, 32-bit offset if the operand size is 32 bits
• 16-bit segment selector, 64-bit offset if the operand size is 64 bits


GCC совместим с ISO C99 http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Integers-impleme...

С99 говорит, что int это такая хрень, в которую можно
всунуть число между INT_MIN и INT_MAX живущие в <limits.h>

http://c0x.coding-guidelines.com/6.2.5.html


#include <stdio.h>
#include <limits.h>
#include <math.h>

int main() {

        printf("short      %lf bit\n", log2((double)SHRT_MAX)  + 1);
        printf("ushort     %lf bit\n", log2((double)USHRT_MAX));
        printf("int        %lf bit\n", log2((double)INT_MAX)   + 1);
        printf("uint       %lf bit\n", log2((double)UINT_MAX));
        printf("long       %lf bit\n", log2((double)LONG_MAX)  + 1);
        printf("ulong      %lf bit\n", log2((double)ULONG_MAX));
        printf("long long  %lf bit\n", log2((double)LLONG_MAX) + 1 );
        printf("ulong long %lf bit\n", log2((double)ULLONG_MAX));

return 0;
}


 

Ваше сообщение
Имя*:
EMail:
Для отправки ответов на email укажите знак ! перед адресом, например, !user@host.ru (!! - не показывать email).
Более тонкая настройка отправки ответов производится в профиле зарегистрированного участника форума.
Заголовок*:
Сообщение*:
  Введите код, изображенный на картинке: КОД
 
При общении не допускается: неуважительное отношение к собеседнику, хамство, унизительное обращение, ненормативная лексика, переход на личности, агрессивное поведение, обесценивание собеседника, провоцирование флейма голословными и заведомо ложными заявлениями. Не отвечайте на сообщения, явно нарушающие правила - удаляются не только сами нарушения, но и все ответы на них. Лог модерирования.



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру