Last update January 16, 2008

Std Type Aliases

std type aliases

Suggestion of modifications to DMD/Phobos

Changed types:

  • real -> extended
  • ireal -> iextended
  • creal -> cextended
  • alias extended real;
  • alias iextended imaginary;
  • alias cextended complex;
Future addition:
  • int128_t, uint128_t (stdint)
New aliases:
  • utf8_t, utf16_t, utf32_t ("stdutf")
  • some people hate the _t suffix with a passion

Older discussions about type names and aliases:

... and a few others


    TYPE        ALIAS     // RANGE

void // void

Integer: (std.stdint) byte int8_t // 8-bit signed ubyte uint8_t // 8-bit unsigned (0x00-0xFF)

short int16_t // 16-bit signed ushort uint16_t // 16-bit unsigned (0x0000-0xFFFF)

int int32_t // 32-bit signed uint uint32_t // 32-bit unsigned (0x00000000-0xFFFFFFFF)

long int64_t // 64-bit signed (could be two int registers) ulong uint64_t // 64-bit unsigned (could be two uint registers)

cent int128_t // 128-bit signed (reserved for future use) ucent uint128_t // 128-bit unsigned (reserved for future use)

Character: (std.stdutf) char utf8_t // \x00-\x7F (ASCII) wchar utf16_t // \u0000-\uD7FF, \uE000-\uFFFF dchar utf32_t // \U00000000-\U0010FFFF? (Unicode)

Floating Point:
      float               // 32-bit single precision (about 6 digits)
     double               // 64-bit double precision (about 15 digits)
   extended       real    // 64/80/128-bit extended precision (platform)

ifloat // idouble // imaginary versions of the above real ones iextended imaginary //

cfloat // cdouble // complex (with both real and imaginary parts) cextended complex //

Implementation: (Public Domain)

It's all implemented using aliases:


 /* Written by Walter Bright
  * Placed into Public Domain

module std.stdint;

/* Exact sizes */

alias byte int8_t; alias ubyte uint8_t; alias short int16_t; alias ushort uint16_t; alias int int32_t; alias uint uint32_t; alias long int64_t; alias ulong uint64_t;

/* At least sizes */

alias byte int_least8_t; alias ubyte uint_least8_t; alias short int_least16_t; alias ushort uint_least16_t; alias int int_least32_t; alias uint uint_least32_t; alias long int_least64_t; alias ulong uint_least64_t;

/* Fastest minimum width sizes */

alias byte int_fast8_t; alias ubyte uint_fast8_t; alias int int_fast16_t; alias uint uint_fast16_t; alias int int_fast32_t; alias uint uint_fast32_t; alias long int_fast64_t; alias ulong uint_fast64_t;

/* Integer pointer holders */

alias int intptr_t; alias uint uintptr_t;

/* Greatest width integer types */

alias long intmax_t; alias ulong uintmax_t;


 module std.stdutf;

/* UTF code units */

alias char utf8_t; // UTF-8 alias wchar utf16_t; // UTF-16 alias dchar utf32_t; // UTF-32

FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: January 16, 2008 20:15 (diff))