Skip to content

Instantly share code, notes, and snippets.

@alibitek
Created June 7, 2014 15:17
Show Gist options
  • Save alibitek/725e7a6a987d0c574c9b to your computer and use it in GitHub Desktop.
Save alibitek/725e7a6a987d0c574c9b to your computer and use it in GitHub Desktop.
#pragma once
#include <cstdint> // for standard integer types
#include <cmath> // for float_t and double_t
/*
* Fastest minimum-width integer types [C11 Standard (ISO/IEC 9899:2011) Section 7.20.1.3]
*
* Each of the following types designates an integer type that is usually fastest to operate
* with among all integer types that have at least the specified width.
*
* The designated type is not guaranteed to be fastest for all purposes; if the implementation has no
* clear grounds for choosing one type over another, it will simply pick some integer type satisfying
* the signedness and width requirements.
*
* The typedef name int_fastN_t designates the fastest signed integer type with a width of at least N.
* The typedef name uint_fastN_t designates the fastest unsigned integer type with a width of at
* least N.
*/
typedef int_fast8_t int8; // -128 to 127
typedef uint_fast8_t uint8; // 0 to 255
typedef int_fast16_t int16; // -32,768 to 32,767
typedef uint_fast16_t uint16; // 0 to 65,535
typedef int_fast32_t int32; // -2,147,483,648 to 2,147,483,647
typedef uint_fast32_t uint32; // 0 to 4,294,967,295
typedef int_fast64_t int64; // -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
typedef uint_fast64_t uint64; // 0 to 18,446,744,073,709,551,615
typedef float_t real32; // 3.4E +/- 38 (7 digits)
typedef double_t real64; // 1.7E +/- 308 (15 digits)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment