Search This Blog

Wednesday, 21 November 2012

Sizes of int, float, double, unsigned, short, unsigned short, long long

In addition to the int and double types, C++ has several other numeric types.
     C++ has two floating-point types. The float type uses half the storage of the double type, but it can only store 6–7 digits. Many years ago, when computers had far less memory than they have today, float was the standard type for floating-point computations, and programmers would indulge in the luxury of “double precision” only when they needed the additional digits. Today, the float type is rarely used.
     By the way, these numbers are called “floating-point” because of their internal representation in the computer. Consider numbers 29600, 2.96, and 0.0296. They can be represented in a very similar way: namely, as a sequence of the significant digits—296—and an indication of the position of the decimal point. When the values are multiplied or divided by 10, only the position of the decimal point changes; it “floats”. Computers use base 2, not base 10, but the principle is the same.


1 comment:

  1. How to change the size of output screen being shown while running the program.

    ReplyDelete