Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

16 bytes-long integer types

Tags:

c++

types

64-bit

I'm compiling a C++ program using GCC on 64bits - machine/OS/ (with -m64 option passed to g++). As expected, sizeof(long double) == 16 – I'm wondering whether there is 16 bytes-long standard type for integers?

P.S. __int128_t is an artificial extension that emulates standard type as I understood. Other than that I didn't find anything.

like image 481
user1681646 Avatar asked Sep 18 '12 23:09

user1681646


People also ask

How many bytes is int 16?

As per the 2-bytes data capacity, an Int16's value capacity is -32768 to +32767.

How many characters is 16 bytes?

A 16 byte field can hold up to 16 ASCII characters, or perhaps 8 CJK glyphs that might encode a short kanji or hanzi password. "A 16 byte field can hold up to 16 ASCII characters, or perhaps 8 CJK glyphs that might encode a short kanji or hanzi password." Assuming that you are using legacy encodings, of course.


1 Answers

Nope, only guaranteed sizes are for char, unsigned char & signed char, and they are 1:

5.3.3 Sizeof [expr.sizeof]

1 The sizeof operator yields the number of bytes in the object representation of its operand. The operand is either an expression, which is not evaluated, or a parenthesized type-id. The sizeof operator shall not be applied to an expression that has function or incomplete type, or to an enumeration type before all its enumerators have been declared, or to the parenthesized name of such types, or to an lvalue that designates a bit-field. sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1. The result of sizeof applied to any other fundamental type (3.9.1) is implementation-defined. [ Note: in particular, sizeof(bool) and sizeof(wchar_t) are implementation-defined.74) —end note ] [ Note: See 1.7 for the definition of byte and 3.9 for the definition of object representation. —end note ]

(emphasis mine)

like image 172
Luchian Grigore Avatar answered Oct 13 '22 23:10

Luchian Grigore