Literal Suffixes for Data Types - C Language Basics

C examples for Language Basics:Variable

Introduction

An integer literal is normally treated as an int by the compiler.

For integers the suffix can be a combination of U and L, for unsigned and long respectively.

C99 added the LL suffix for the long long type.

The order and casing of these letters do not matter.

Demo Code

#include <stdio.h>

int main() {// w w w  .  j  a va 2  s .  co  m
    int i = 10;
    long l = 10L;
    unsigned long ul = 10UL;
}

A floating-point literal is treated as a double.

The F or f suffix can be used to specify that a literal is of the float type.

The L or l suffix specifies the long double type.

Demo Code

#include <stdio.h>

int main() {//from  w w  w . j  a  va  2  s.  com
    float f = 1.23F;
    double d = 1.23;
    long double ld = 1.23L;
}

Related Tutorials