C - Data Type Number Type

Introduction

When programming, you use only two types of numbers:

  • Integer
  • Float

Integer

An integer is a whole number - no fractional part.

It can be positive or negative.

It can be a single digit, zero, or humongous value.

Float

A float is a number that has a fractional part - a decimal place.

Examples of floats are 3.14, 0.1, and 6.023e23.

That last number is written in scientific notation, which means that it's the value 6.023 time 10 power 23.

When typing a small floating-point value, remember to prefix the decimal point with a zero, for example, 0.00008.

When typing a float value without a decimal part, type the decimal and a zero anyway: 1000000.0

Integers and floats can be either positive or negative.

The term float is short for floating point.

Related Topics

Exercise