Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2024/25/2
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

primitive types and type properties

Primitive types

These tables are from Programming in D.

They have the same size on every platform. real is the only exception.

TypeDefinitionInitial Value
boolBoolean typefalse
TypeDefinitionInitial Value
bytesigned 8 bits0
ubyteunsigned 8 bits0
shortsigned 16 bits0
ushortunsigned 16 bits0
intsigned 32 bits0
uintunsigned 32 bits0
longsigned 64 bits0L
ulongunsigned 64 bits0LU
TypeDefinitionInitial Value
float32 bitsfloat.nan
double64 bitsdouble.nan
realat least 64 bits but can be more if the hardware provides morereal.nan
TypeDefinitionInitial Value
charUTF-8 code unit0xFF
wcharUTF-16 code unit0xFFFF
dcharUTF-32 code unit and Unicode code point0x0000FFFF

size_t

"You will come across the size_t type as well. size_t is not a separate type but an alias of an existing unsigned type. Its name comes from "size type". It is the most suitable type to represent concepts like size or count. size_t is large enough to represent the number of bytes of the memory that a program can potentially be using. Its actual size depends on the system: uint on a 32-bit system and ulong on a 64-bit system." (from Programming in D)

writeln("Type: ", size_t.stringof); // "ulong" (as a string)
writeln("Length in bytes: ", size_t.sizeof); // 8

Type properties

(1) type properties
#include <limits.h>
#include <stdio.h>

int main()
{
    printf("Length in bytes: %d\n", sizeof(int)); // 4
    printf("Minimum value: %d\n", INT_MIN);       // -2147483648
    printf("Maximum value: %d\n", INT_MAX);       // 2147483647

    return 0;
}
import std.stdio;

void main()
{
    writeln("Type: ", int.stringof); // "int" (as a string)
    writeln("Length in bytes: ", int.sizeof); // 4
    writeln("Minimum value: ", int.min); // -2147483648
    writeln("Maximum value: ", int.max); // 2147483647
    writeln("Initial value: ", int.init); // 0

    int x = 2;
    writeln(x.stringof); // "x" (as string)
    writeln(typeof(x).stringof); // "int" (as string)
    writeln(typeid(typeof(x))); // int (as object.TypeInfo)
    writeln(typeid(typeof(x)).stringof); // "typeid(int)" (as string)
}
def main():
    x = 3
    print(type(x))  # <class 'int'>
int value = 100;

typeof(value) value2;  // equivalent to: int value2;
typeof(100) value3;  // equivalent to: int value3;
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2025 June 28, 19:29