Why float is not considered as an integral type?

An integral type is one which has only integers - whole numbers. The purpose of floating point types is to represent non-integers as well.

From the Wikipedia page on integer (computer science):

In computer science, an integer is a datum of integral data type, a data type which represents some finite subset of the mathematical integers.


I suspect your confusion is which meaning of integral applies:

Definition of INTEGRAL

1 a : essential to completeness : constituent "an integral part of the curriculum"

b (1) : being, containing, or relating to one or more mathematical integers (2) : relating to or concerned with mathematical integration or the results of mathematical integration

It's not (1a) essential to completeness (which float would be), but (1b) relating to the integers.


Jon's answer is right, but here's a short overview of some type traits that might help you:

  • is_integral checks if a type is integral type
  • is_floating_point checks if a type is floating point type
  • is_arithmetic checks if a type is either integral or floating point type

And here is a nice graph from Howard Hinnant that shows the relationship between the type categories.