Conversions Table

external bool string byte signed byte short unsigned short int unsigned int long unsigned long float double char
external ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✖ ✖ ✖ ✔ ✔
bool ✔ ✔ ✖1 ✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖
string ✔ ✖ ✔ ✖ ✖ ✖ ✖ ✖2 ✖ ✖ ✖ ✖ ✖ ✖
byte ✔ ❗ ✖1 ✔ ❗ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ❗
signed byte ✔ ❗ ✖1 ❗ ✔ ✔ ❗ ✔ ❗ ✔ ❗ ✔ ✔ ❗
short ✔ ❗ ✖1 ❗ ❗ ✔ ❗ ✔ ❗ ✔ ❗ ✔ ✔ ❗
unsigned short ✔ ❗ ✖1 ❗ ❗ ❗ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ❗
int ✔ ❗ ✖1 ❗ ❗ ❗ ❗ ✔ ❗ ✔ ❗ ✔ ✔ ❗
unsigned int ✔ ❗ ✖1 ❗ ❗ ❗ ❗ ❗ ✔ ✔ ✔ ✔ ✔ ❗
long ✖ ❗ ✖1 ❗ ❗ ❗ ❗ ❗ ❗ ✔ ❗ ✔ ✔ ❗
unsigned long ✖ ❗ ✖1 ❗ ❗ ❗ ❗ ❗ ❗ ❗ ✔ ✔ ✔ ❗
float ✖ ❗ ✖1 ❗ ❗ ❗ ❗ ❗ ❗ ❗ ❗ ✔ ✔ ❗
double ✔ ❗ ✖1 ❗ ❗ ❗ ❗ ❗ ❗ ❗ ❗ ❗ ✔ ❗
char ✔ ❗ ✖1 ❗ ❗ ❗ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔

Legend

✔ Implicit conversion available
❗ Explicit conversion (via the type cast operator) available
✖ No conversion available

Left is "Conversion From", Top is "Conversion To"

 

1 The Standard Library wrapper classes provide toString() methods for these types

2 string can be explicitly converted to int using the unary plus operator but not with the type cast operator

See Also

Share

HTML | BBCode | Direct Link