Skip to content

Instantly share code, notes, and snippets.

@jkoop
Last active November 22, 2023 15:08
Show Gist options
  • Save jkoop/f604a7148740b7fef88859c30a89aeb1 to your computer and use it in GitHub Desktop.
Save jkoop/f604a7148740b7fef88859c30a89aeb1 to your computer and use it in GitHub Desktop.
terse shorthands for numeric types in C
/**
* numbers.h - Terse shorthands for numeric types
* Copyright (c) 2023 Joe Koop
* License: The MIT License (MIT)
*/
#include <stdint.h>
// E for "exact"
typedef int8_t i8e;
typedef uint8_t u8e;
typedef int16_t i16e;
typedef uint16_t u1e;
typedef int32_t i32e;
typedef uint32_t u3e;
typedef int64_t i64e;
typedef uint64_t u64e;
// because I usually don't care; I want it to be fast
typedef int_fast8_t i8;
typedef uint_fast8_t u8;
typedef int_fast16_t i16;
typedef uint_fast16_t u16;
typedef int_fast32_t i32;
typedef uint_fast32_t u32;
typedef int_fast64_t i64;
typedef uint_fast64_t u64;
// none of my hardware supports any kind of f16 type
typedef float f32;
typedef double f64;
typedef long double f128;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment