Il seguente sorgente C, già proposto più volte in numerose salse su questi forum e altrove, mette a confronto neofiti e non con i limiti dei tipi numerici di default supportati dai vari compilatori x86 (e oltre).
Si veda anche
questo breve articolo per ulteriori indicazioni in merito.
#include <stdio.h>
#include <limits.h>
#include <float.h>
#if defined(__BORLANDC__) || defined(__TURBOC__)
const char Compiler[] = "** Compiled with Borland C++"
" **";
#endif
#ifdef _MSC_VER
const char Compiler[] = "** Compiled with Visual C/C++"
" **";
#endif
#ifdef __WATCOMC__
const char Compiler[] = "** Compiled with Open Watcom"
" **";
#endif
#ifdef __DMC__
const char Compiler[] = "** Compiled with Digital Mars"
" **";
#endif
/* Versione assai approssimativa e pressapochista, ma utile */
#if defined(UINT64_MAX) && !defined(_UI64_MAX)
#define _UI64_MAX UINT64_MAX
#define _I64_MAX INT64_MAX
#define _I64_MIN INT64_MIN
#endif
#define HSEP_STAR "************************************************************"
#define HSEP_LINE "------------------------------------------------------------"
int main(void)
{
puts("\n" HSEP_STAR);
puts(Compiler);
puts(HSEP_STAR);
printf("- unsigned:\n"
"char...........: [0, %u] (%d bits per char)\n",
UCHAR_MAX, CHAR_BIT);
printf("short int......: [0, %u]\n", USHRT_MAX);
printf("int............: [0, %u]\n", UINT_MAX);
printf("long int.......: [0, %lu]\n", ULONG_MAX);
#ifdef _UI64_MAX
printf("long int 64....: [0, %I64u]\n", _UI64_MAX);
#endif
puts(HSEP_LINE);
printf("- signed:\n"
"char...........: [%d, %d]\n", SCHAR_MIN, SCHAR_MAX);
printf("short int......: [%d, %d]\n", SHRT_MIN, SHRT_MAX);
printf("int............: [%d, %d]\n", INT_MIN, INT_MAX);
printf("long int.......: [%ld, %ld]\n", LONG_MIN, LONG_MAX);
#ifdef _I64_MAX
printf("long int 64....: [%I64d, %I64d]\n", _I64_MIN, _I64_MAX);
#endif
puts(HSEP_LINE);
printf("float..........: [%g, %g]\n", FLT_MIN, FLT_MAX);
printf("double.........: [%g, %g]\n", DBL_MIN, DBL_MAX);
printf("long double....: [%Lg, %Lg]\n", LDBL_MIN, LDBL_MAX);
puts(HSEP_LINE);
printf("FLT_EPSILON....: %g\n", FLT_EPSILON);
printf("DBL_EPSILON....: %g\n", DBL_EPSILON);
printf("LDBL_EPSILON...: %Lg\n", LDBL_EPSILON);
puts(HSEP_STAR);
return (0);
}