answersLogoWhite

0


Best Answer

The C++ standard does not define the magnitude for any data type, only that a char must be at least 8-bits in length in order to represent all the characters in the basic execution character set (Unicode UTF-8 encoding). In the majority of implementations this equates to at least 1 byte, however nothing is stated about the length of a byte. In most cases a byte is 8-bits in length, however this needn't always be the case. Some architectures still use a 7-bit byte in which case a char would require at least 2 bytes.

The C++ standard defines 5 standard signed integer types: signed char, signed short int, signed int, signed long int and signed long long. In this list, each type is at least as long as those preceding it, but nothing is said about the actual lengths which is, again, implementation defined. The standard defines 5 unsigned equivalents of the signed integrals, each of which is the same length as its corresponding signed version. The standard also defines a special data type known as a plain char. A plain char data type may be signed or unsigned (as defined by the implementation) but is completely independent of the signed and unsigned char. The only thing that is certain about all the char data types is that they are all the same length -- at least 1 byte.

In order to determine the magnitude for any fundamental data type, you need to query the implementation directly. This is achieved by including the header file. With this header in place, you have access to the macro constants that determine how many bits are in a char (CHAR_BIT) as well as the minimum and maximum values for all 11 of the fundamental data types. E.g., the maximum positive value for an unsigned long int is defined by the ULONG_MAX macro.

Knowing how many bits are in a char is useful because you can use this in conjunction with the sizeof() operator to determine how many bits are used by any data type. This is because all data types (including user-defined data types) are made up of one or more char data types, thus if a data type occupies exactly 4 chars, then it must utilise at least 4 times CHAR_BIT bits.

The 3 floating point data types are float, double and long double. There are no unsigned variants thus the signed modifier does not apply to floating point types. The magnitudes for each type can be found in the header, which provides specialisations of the std::numeric_limits template.

The bool data type can only be true or false and cannot be modified with signed, unsigned long or short. Numerically speaking it can only be said to be non-zero (for true) or zero (for false), however non-zero typically means all bits are set, the polar opposite of zero and the binary equivalent of -1 for a signed integral using twos-complement notation. In other words there is no positive value you can place in a bool: it's either -1 or 0 and zero is neither positive nor negative.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the magnitude of the largest positive value you can place in a bool a char an int a float a double?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the range of float?

i wann't ask the range of double float and long double float??


Can there be a negative float?

A float variable can store both positive and negative numbers.


What is the largest part of a bathyscaphe?

The float


What paper boat floats the longest?

The paper boat with the largest volume will float the longest basically the largest paper boat will float the longest.


Why should double data type is preferable over float data type?

by default any float value is double


If you have a variable like float monthlypayment error message says found double requires float in monthlyPayment mortgageFunds interestRate?

Just use a double instead of a float. Double allows for a larger number and you won't produce that error.


What are two Java primitive types store floating-point numbers?

In Java, you can use either a float or a double


What is another word for float in c plus plus?

double, but double is nearly twice the precision of float, so its not really the same thing.


Is the double a modifier in c plus plus?

A double is a floating point type, greater than or equal in size to a float.


Do protons float areound in solution as tiny positive charge?

no.


Can a double value be assigned to float variable?

THIS IS FOR JAVA i don't know about anything about other languages yes it can be assignedthe syntax is:int (number) = (float) numberFOR EXAMPLE:int = a;a = (float ) 5.5;if the (float) is not there then in Java it gives an error saying precision loss of data type


When you assign the value 5.628 into a float variable how can you avoid getting the decimal truncation warning?

When assigning a literal value, such as 5.628, to a float variable, you can avoid the decimal truncation warning by either using the float form of the constant (float var = 5.628f), typecasting the assignment (float var = (float) 5.628), or by making the variable double (double var = 5.628).