Conversions

From Coder Merlin
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Boeing, N780BA, B747-409(LCF) Dreamlifter

Prerequisites[edit]

Introduction[edit]

In some cases we have a value of one type but want to use it in another context, as a different type. Depending on language, this may be referred to as "type conversion", "type casting", or "type coercion". Often, type casting refers to the mere re-interpretation of existing bits, while type conversion creates a new representation of data as a different type.

Type Casting[edit]

When type casting, we consider an existing bit pattern as other than that originally declared. For example, consider the following C program:

#include <stdio.h>
int main(int argc, char *argv[]) {
  int c = 65;
  printf("The value is: %i", c);
  printf("The value is: %c", c);
  return 0;
}

We declare an integer variable,

Type Conversion[edit]

Topic Headers[edit]

Key Concepts[edit]

Exercises[edit]

References[edit]