answersLogoWhite

0

How many bytes in long?

Updated: 8/11/2023
User Avatar

Wiki User

11y ago

Best Answer

The set of datatypes and the definition of each member is dependent on hardware, the language standard, and the language implementation. Not knowing which language the question relates to is particularly limiting.

In Java, a long consists of 8 bytes. This is also generally true for C and C++, depending upon the compiler used. See the related links for further details.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

7y ago

The length of a long in C++ is implementation-defined. It is guaranteed to be at least as long as an int. The following shows the relationship between the integer type lengths.

CHAR_BITS = number of bits in a byte; implementation-defined (at least 8 bits)

sizeof (char) = 1 (byte)

sizeof (short) >= sizeof (char)

sizeof (int) >= sizeof (short)

sizeof (long) >= sizeof (int)

sizeof (long long) >= sizeof (long)

For portability, always use the sizeof() operator to obtain type lengths. If you require an integer with a specific bit length across all platforms, use the fixed-width integer types found in the standard library header. E.g., for a 32-bit signed integer, use the std::int32_t data type.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

8 bytes.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How many bytes in long?
Write your answer...
Submit
Still have questions?
magnify glass
imp