The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Personal tools

Type Sizes.es

From the makers of InspIRCd.

Jump to: navigation, search

Contents

Tamaño de los Tipos en varias maquinas, para referencia

Esta es una buena fuente de desarrollo, por favor contribuye con los resultados de tu sistema si tu notas una notable diferencia en el sistema o un sistema similar con diferentes resultados.

Reglas de C++ en el tamaño de los tipos

1 === sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
1 <= sizeof(bool) <= sizeof(long)
sizeof(char) <= sizeof(wchar_t) <= sizeof(long)
sizeof(float) <= sizeof(double) <= sizeof(long double)

N == (char, short, int, long)
sizeof(N) === sizeof(unsigned N) === sizeof(signed N)

char >= 8 bits
short >= 16 bits
long >= 32 bits

Resultados de distintos Sistemas

Todos los resultados fueron generados con el siguiente programa en C++:

#include <iostream>

#define PRINT(x) (std::cout << "sizeof(" #x ") = " << sizeof(x) << std::endl)

int main()
{
        PRINT(bool);
        PRINT(char);
        PRINT(wchar_t);
        PRINT(short);
        PRINT(int);
        PRINT(float);
        PRINT(double);
        PRINT(long double);
        PRINT(long);
        PRINT(long long);
        return 0;
}

AMD64 Gentoo Linux 64bit, GCC Gentoo 3.4.6-r1

sizeof(bool) = 1
sizeof(char) = 1
sizeof(wchar_t) = 4
sizeof(short) = 2
sizeof(int) = 4
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 16
sizeof(long) = 8
sizeof(long long) = 8

i386 FreeBSD 32bit, GCC 3.4.2 [FreeBSD]

sizeof(bool) = 1
sizeof(char) = 1
sizeof(wchar_t) = 4
sizeof(short) = 2
sizeof(int) = 4
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 12
sizeof(long) = 4
sizeof(long long) = 8