kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: SQL-based authentication
C#: using System.Security.Cryptography;
using System.Text;

namespace rosettaMySQL
{
    class Hasher
    {
        private static string _BytesToHex(byte[] input)
        {
            var strBuilder = new StringBuilder();
            foreach (byte _byte in input)
            {
                strBuilder.Append(_byte.ToString("x2"));
            }
            return strBuilder.ToString();
        }

        public static string Hash(string salt, string input)
        {
            using (MD5 md5 = new MD5CryptoServiceProvider())
            {
                var bytes = Encoding.Default.GetBytes(salt + input);
                var data = md5.ComputeHash(bytes);
                return _BytesToHex(data);
            }
        }

        public static string GenSalt()
        {
            using (RandomNumberGenerator rng = new RNGCryptoServiceProvider())
            {
                var salt = new byte[16];
                rng.GetBytes(salt);
                return _BytesToHex(salt);
            }
        }
    }
}

Go: package main

import (
    "bytes"
    "crypto/md5"
    "crypto/rand"
    "database/sql"
    "fmt"

    _ "github.com/go-sql-driver/mysql"
)

func connectDB() (*sql.DB, error) {
    return sql.Open("mysql", "rosetta:code@/rc")
}

func createUser(db *sql.DB, user, pwd string) error {
    salt := make([]byte, 16)
    rand.Reader.Read(salt)
    _, err := db.Exec(`insert into users (username, pass_salt, pass_md5)
        values (?, ?, ?)`, user, salt, saltHash(salt, pwd))
    if err != nil {
        return fmt.Errorf("User %s already exits", user)
    }
    return nil
}

func authenticateUser(db *sql.DB, user, pwd string) error {
    var salt, hash []byte
    row := db.QueryRow(`select pass_salt, pass_md5 from users
        where username=?`, user)
    if err := row.Scan(&salt, &hash); err != nil {
        return fmt.Errorf("User %s unknown", user)
    }
    if !bytes.Equal(saltHash(salt, pwd), hash) {
        return fmt.Errorf("User %s invalid password", user)
    }
    return nil
}

func saltHash(salt []byte, pwd string) []byte {
    h := md5.New()
    h.Write(salt)
    h.Write([]byte(pwd))
    return h.Sum(nil)
}

func main() {
    
    db, err := connectDB()
    defer db.Close()
    createUser(db, "sam", "123")
    err = authenticateUser(db, "sam", "123")
    if err == nil {
        fmt.Println("User sam authenticated")
    }

    
    fmt.Println()
    
    rows, _ := db.Query(`select username, pass_salt, pass_md5 from users`)
    var user string
    var salt, hash []byte
    for rows.Next() {
        rows.Scan(&user, &salt, &hash)
        fmt.Printf("%s %x %x\n", user, salt, hash)
    }
    
    err = createUser(db, "sam", "123")
    fmt.Println(err)
    
    err = authenticateUser(db, "pam", "123")
    fmt.Println(err)
    
    err = authenticateUser(db, "sam", "1234")
    fmt.Println(err)
    
    db.Exec(`truncate table users`)
}
Task: SQL-based authentication
C#: using System.Security.Cryptography;
using System.Text;

namespace rosettaMySQL
{
    class Hasher
    {
        private static string _BytesToHex(byte[] input)
        {
            var strBuilder = new StringBuilder();
            foreach (byte _byte in input)
            {
                strBuilder.Append(_byte.ToString("x2"));
            }
            return strBuilder.ToString();
        }

        public static string Hash(string salt, string input)
        {
            using (MD5 md5 = new MD5CryptoServiceProvider())
            {
                var bytes = Encoding.Default.GetBytes(salt + input);
                var data = md5.ComputeHash(bytes);
                return _BytesToHex(data);
            }
        }

        public static string GenSalt()
        {
            using (RandomNumberGenerator rng = new RNGCryptoServiceProvider())
            {
                var salt = new byte[16];
                rng.GetBytes(salt);
                return _BytesToHex(salt);
            }
        }
    }
}

PHP: function connect_db($database, $db_user, $db_password, $host = 'localhost', $port = NULL, $die = false) {





	if(!$db_handle = @mysql_connect($host.($port ? ':'.$port : ''), $db_user, $db_password)) {
		if($die)
			die("Can't connect to MySQL server:\r\n".mysql_error());
		else
			return false;
	}
	if(!@mysql_select_db($database, $db_handle)) {
		if($die)
			die("Can't select database '$database':\r\n".mysql_error());
		else
			return false;
	}
	return $db_handle;
}

function create_user($username, $password, $db_handle) {


	if(strlen($username) > 32)
		return false;

	$salt = '';
	do {
		$salt .= chr(mt_rand(32, 254));
	} while(strlen($salt) < 16);

	$pass_md5 = md5($salt.$password);

	$username = mysql_real_escape_string($username);
	$salt = mysql_real_escape_string($salt);

	if(!@mysql_query("INSERT INTO users (username,pass_salt,pass_md5) VALUES('$username','$salt','$pass_md5')", $db_handle))
		return false;

	return mysql_insert_id($db_handle);
}

function authenticate_user($username, $password, $db_handle) {



	$safe_username = mysql_real_escape_string($username);

	if(!$result = @mysql_query("SELECT * FROM users WHERE username='$safe_username'", $db_handle))
		return false;

	$row = @mysql_fetch_assoc($result);

	if(md5($row['pass_salt'].$password) != $row['pass_md5'])
		return false;

	return $row['userid'];
}
Task: Implicit type conversion
C: #include <stdio.h>
main(){

    unsigned char uc; char c;
    enum{e1, e2, e3}e123;
    short si; int i; long li;
    unsigned short su; unsigned u; unsigned long lu;
    float sf; float f; double lf; long double llf;
    union {char c; unsigned u; int i; float f; }ucuif;  
    struct {char c; unsigned u; int i; float f; }scuif; 
    int ai[99];
    int (*rai)[99];
    int *ri;
    uc = '1';

    c=uc;
    si=uc; si=c;
    su=uc; su=c; su=si;
    i=uc;  i=c;  i=si;  i=su;
    e123=i; i=e123;
    u=uc;  u=c;  u=si;  u=su;  u=i;
    li=uc; li=c; li=si; li=su; li=i; li=u;
    lu=uc; lu=c; lu=si; lu=su; lu=i; lu=u; lu=li;
    sf=uc; sf=c; sf=si; sf=su; sf=i; sf=u; sf=li; sf=lu;
    f=uc;  f=c;  f=si;  f=su;  f=i;  f=u;  f=li;  f=lu;  f=sf;
    lf=uc; lf=c; lf=si; lf=su; lf=i; lf=u; lf=li; lf=lu; lf=sf; lf=f;
    llf=uc;llf=c;llf=si;llf=su;llf=i;llf=u;llf=li;llf=lu;llf=sf;llf=f;llf=lf;



    rai = ai; 
    ri = ai;  

    printf("%LF was increasingly cast from %d from %d from %d from %d from %d bytes from '%c'\n",
           llf=(lf=(i=(si=c))), sizeof llf, sizeof lf, sizeof i, sizeof si,sizeof c, c);
}

C#: byte aByte = 2;
short aShort = aByte;
int anInt = aShort;
long aLong = anInt;

float aFloat = 1.2f;
double aDouble = aFloat;

BigInteger b = 5;
Complex c = 2.5;
Task: Implicit type conversion
C: #include <stdio.h>
main(){

    unsigned char uc; char c;
    enum{e1, e2, e3}e123;
    short si; int i; long li;
    unsigned short su; unsigned u; unsigned long lu;
    float sf; float f; double lf; long double llf;
    union {char c; unsigned u; int i; float f; }ucuif;  
    struct {char c; unsigned u; int i; float f; }scuif; 
    int ai[99];
    int (*rai)[99];
    int *ri;
    uc = '1';

    c=uc;
    si=uc; si=c;
    su=uc; su=c; su=si;
    i=uc;  i=c;  i=si;  i=su;
    e123=i; i=e123;
    u=uc;  u=c;  u=si;  u=su;  u=i;
    li=uc; li=c; li=si; li=su; li=i; li=u;
    lu=uc; lu=c; lu=si; lu=su; lu=i; lu=u; lu=li;
    sf=uc; sf=c; sf=si; sf=su; sf=i; sf=u; sf=li; sf=lu;
    f=uc;  f=c;  f=si;  f=su;  f=i;  f=u;  f=li;  f=lu;  f=sf;
    lf=uc; lf=c; lf=si; lf=su; lf=i; lf=u; lf=li; lf=lu; lf=sf; lf=f;
    llf=uc;llf=c;llf=si;llf=su;llf=i;llf=u;llf=li;llf=lu;llf=sf;llf=f;llf=lf;



    rai = ai; 
    ri = ai;  

    printf("%LF was increasingly cast from %d from %d from %d from %d from %d bytes from '%c'\n",
           llf=(lf=(i=(si=c))), sizeof llf, sizeof lf, sizeof i, sizeof si,sizeof c, c);
}

C#: #include <iostream>
#include <math.h>

struct PolarPoint;


struct CartesianPoint
{
    double x;
    double y;
    
    
    operator PolarPoint();
};


struct PolarPoint
{
    double rho;
    double theta;
    
    
    operator CartesianPoint();
};


CartesianPoint::operator PolarPoint()
{
    return PolarPoint
    {
        sqrt(x*x + y*y),
        atan2(y, x)
    };
}


PolarPoint::operator CartesianPoint()
{
    return CartesianPoint 
    {
        rho * cos(theta),
        rho * sin(theta)
    };
}

int main()
{
    
    CartesianPoint cp1{2,-2};
    
    PolarPoint pp1 = cp1;
    
    CartesianPoint cp2 = pp1;
    
    std::cout << "rho=" << pp1.rho << ", theta=" << pp1.theta << "\n"; 
    std::cout << "x=" << cp2.x << ", y=" << cp2.y << "\n"; 
}
Task: Implicit type conversion
C: #include <stdio.h>
main(){

    unsigned char uc; char c;
    enum{e1, e2, e3}e123;
    short si; int i; long li;
    unsigned short su; unsigned u; unsigned long lu;
    float sf; float f; double lf; long double llf;
    union {char c; unsigned u; int i; float f; }ucuif;  
    struct {char c; unsigned u; int i; float f; }scuif; 
    int ai[99];
    int (*rai)[99];
    int *ri;
    uc = '1';

    c=uc;
    si=uc; si=c;
    su=uc; su=c; su=si;
    i=uc;  i=c;  i=si;  i=su;
    e123=i; i=e123;
    u=uc;  u=c;  u=si;  u=su;  u=i;
    li=uc; li=c; li=si; li=su; li=i; li=u;
    lu=uc; lu=c; lu=si; lu=su; lu=i; lu=u; lu=li;
    sf=uc; sf=c; sf=si; sf=su; sf=i; sf=u; sf=li; sf=lu;
    f=uc;  f=c;  f=si;  f=su;  f=i;  f=u;  f=li;  f=lu;  f=sf;
    lf=uc; lf=c; lf=si; lf=su; lf=i; lf=u; lf=li; lf=lu; lf=sf; lf=f;
    llf=uc;llf=c;llf=si;llf=su;llf=i;llf=u;llf=li;llf=lu;llf=sf;llf=f;llf=lf;



    rai = ai; 
    ri = ai;  

    printf("%LF was increasingly cast from %d from %d from %d from %d from %d bytes from '%c'\n",
           llf=(lf=(i=(si=c))), sizeof llf, sizeof lf, sizeof i, sizeof si,sizeof c, c);
}

C++: #include <iostream>
#include <math.h>

struct PolarPoint;


struct CartesianPoint
{
    double x;
    double y;
    
    
    operator PolarPoint();
};


struct PolarPoint
{
    double rho;
    double theta;
    
    
    operator CartesianPoint();
};


CartesianPoint::operator PolarPoint()
{
    return PolarPoint
    {
        sqrt(x*x + y*y),
        atan2(y, x)
    };
}


PolarPoint::operator CartesianPoint()
{
    return CartesianPoint 
    {
        rho * cos(theta),
        rho * sin(theta)
    };
}

int main()
{
    
    CartesianPoint cp1{2,-2};
    
    PolarPoint pp1 = cp1;
    
    CartesianPoint cp2 = pp1;
    
    std::cout << "rho=" << pp1.rho << ", theta=" << pp1.theta << "\n"; 
    std::cout << "x=" << cp2.x << ", y=" << cp2.y << "\n"; 
}
Task: Implicit type conversion
C: #include <stdio.h>
main(){

    unsigned char uc; char c;
    enum{e1, e2, e3}e123;
    short si; int i; long li;
    unsigned short su; unsigned u; unsigned long lu;
    float sf; float f; double lf; long double llf;
    union {char c; unsigned u; int i; float f; }ucuif;  
    struct {char c; unsigned u; int i; float f; }scuif; 
    int ai[99];
    int (*rai)[99];
    int *ri;
    uc = '1';

    c=uc;
    si=uc; si=c;
    su=uc; su=c; su=si;
    i=uc;  i=c;  i=si;  i=su;
    e123=i; i=e123;
    u=uc;  u=c;  u=si;  u=su;  u=i;
    li=uc; li=c; li=si; li=su; li=i; li=u;
    lu=uc; lu=c; lu=si; lu=su; lu=i; lu=u; lu=li;
    sf=uc; sf=c; sf=si; sf=su; sf=i; sf=u; sf=li; sf=lu;
    f=uc;  f=c;  f=si;  f=su;  f=i;  f=u;  f=li;  f=lu;  f=sf;
    lf=uc; lf=c; lf=si; lf=su; lf=i; lf=u; lf=li; lf=lu; lf=sf; lf=f;
    llf=uc;llf=c;llf=si;llf=su;llf=i;llf=u;llf=li;llf=lu;llf=sf;llf=f;llf=lf;



    rai = ai; 
    ri = ai;  

    printf("%LF was increasingly cast from %d from %d from %d from %d from %d bytes from '%c'\n",
           llf=(lf=(i=(si=c))), sizeof llf, sizeof lf, sizeof i, sizeof si,sizeof c, c);
}

Go: package main

import "fmt"

func main() {
    

    
    
    var i int32 = 1
    fmt.Printf("i : type %-7T value %d\n", i, i)

    
    
    
    j := 2
    fmt.Printf("j : type %-7T value %d\n", j, j)

    
    
    
    
    var k int64 = int64(i) + int64(j)
    fmt.Printf("k : type %-7T value %d\n", k, k)

    
    
    

    
    
    
    var l int8 = 4.0
    fmt.Printf("l : type %-7T value %d\n", l, l)

    
    
    
    m := 0.3 + float64(l) + 0.7
    fmt.Printf("m : type %-7T value %g\n", m, m)
}
Task: Implicit type conversion
C: #include <stdio.h>
main(){

    unsigned char uc; char c;
    enum{e1, e2, e3}e123;
    short si; int i; long li;
    unsigned short su; unsigned u; unsigned long lu;
    float sf; float f; double lf; long double llf;
    union {char c; unsigned u; int i; float f; }ucuif;  
    struct {char c; unsigned u; int i; float f; }scuif; 
    int ai[99];
    int (*rai)[99];
    int *ri;
    uc = '1';

    c=uc;
    si=uc; si=c;
    su=uc; su=c; su=si;
    i=uc;  i=c;  i=si;  i=su;
    e123=i; i=e123;
    u=uc;  u=c;  u=si;  u=su;  u=i;
    li=uc; li=c; li=si; li=su; li=i; li=u;
    lu=uc; lu=c; lu=si; lu=su; lu=i; lu=u; lu=li;
    sf=uc; sf=c; sf=si; sf=su; sf=i; sf=u; sf=li; sf=lu;
    f=uc;  f=c;  f=si;  f=su;  f=i;  f=u;  f=li;  f=lu;  f=sf;
    lf=uc; lf=c; lf=si; lf=su; lf=i; lf=u; lf=li; lf=lu; lf=sf; lf=f;
    llf=uc;llf=c;llf=si;llf=su;llf=i;llf=u;llf=li;llf=lu;llf=sf;llf=f;llf=lf;



    rai = ai; 
    ri = ai;  

    printf("%LF was increasingly cast from %d from %d from %d from %d from %d bytes from '%c'\n",
           llf=(lf=(i=(si=c))), sizeof llf, sizeof lf, sizeof i, sizeof si,sizeof c, c);
}

Java: public class ImplicitTypeConversion{
   public static void main(String...args){
      System.out.println( "Primitive conversions" );
      byte  by = -1;
      short sh = by;
      int   in = sh;
      long  lo = in;
      System.out.println( "byte value    -1         to 3 integral types:  " + lo );

      float  fl = 0.1f;
      double db = fl;
      System.out.println( "float value   0.1        to double:            " + db );

      int    in2 = -1;
      float  fl2 = in2;
      double db2 = fl2;
      System.out.println( "int value     -1         to float and double:  " + db2 );

      int    in3 = Integer.MAX_VALUE;
      float  fl3 = in3;
      double db3 = fl3;
      System.out.println( "int value     " + Integer.MAX_VALUE + " to float and double:  " + db3 );

      char   ch  = 'a';
      int    in4 = ch;
      double db4 = in4;
      System.out.println( "char value    '" + ch + "'        to int and double:    " + db4 );

      System.out.println();
      System.out.println( "Boxing and unboxing" );
      Integer in5 = -1;
      int     in6 = in5;
      System.out.println( "int  value    -1         to Integer and int:   " + in6 );

      Double db5 = 0.1;
      double db6 = db5;
      System.out.println( "double value  0.1        to Double and double: " + db6 );
   }
}
Task: Implicit type conversion
C#: byte aByte = 2;
short aShort = aByte;
int anInt = aShort;
long aLong = anInt;

float aFloat = 1.2f;
double aDouble = aFloat;

BigInteger b = 5;
Complex c = 2.5; 

C++: #include <iostream>
#include <math.h>

struct PolarPoint;


struct CartesianPoint
{
    double x;
    double y;
    
    
    operator PolarPoint();
};


struct PolarPoint
{
    double rho;
    double theta;
    
    
    operator CartesianPoint();
};


CartesianPoint::operator PolarPoint()
{
    return PolarPoint
    {
        sqrt(x*x + y*y),
        atan2(y, x)
    };
}


PolarPoint::operator CartesianPoint()
{
    return CartesianPoint 
    {
        rho * cos(theta),
        rho * sin(theta)
    };
}

int main()
{
    
    CartesianPoint cp1{2,-2};
    
    PolarPoint pp1 = cp1;
    
    CartesianPoint cp2 = pp1;
    
    std::cout << "rho=" << pp1.rho << ", theta=" << pp1.theta << "\n"; 
    std::cout << "x=" << cp2.x << ", y=" << cp2.y << "\n"; 
}
Task: Implicit type conversion
C++: #include <iostream>
#include <math.h>

struct PolarPoint;


struct CartesianPoint
{
    double x;
    double y;
    
    
    operator PolarPoint();
};


struct PolarPoint
{
    double rho;
    double theta;
    
    
    operator CartesianPoint();
};


CartesianPoint::operator PolarPoint()
{
    return PolarPoint
    {
        sqrt(x*x + y*y),
        atan2(y, x)
    };
}


PolarPoint::operator CartesianPoint()
{
    return CartesianPoint 
    {
        rho * cos(theta),
        rho * sin(theta)
    };
}

int main()
{
    
    CartesianPoint cp1{2,-2};
    
    PolarPoint pp1 = cp1;
    
    CartesianPoint cp2 = pp1;
    
    std::cout << "rho=" << pp1.rho << ", theta=" << pp1.theta << "\n"; 
    std::cout << "x=" << cp2.x << ", y=" << cp2.y << "\n"; 
}

Go: package main

import "fmt"

func main() {
    

    
    
    var i int32 = 1
    fmt.Printf("i : type %-7T value %d\n", i, i)

    
    
    
    j := 2
    fmt.Printf("j : type %-7T value %d\n", j, j)

    
    
    
    
    var k int64 = int64(i) + int64(j)
    fmt.Printf("k : type %-7T value %d\n", k, k)

    
    
    

    
    
    
    var l int8 = 4.0
    fmt.Printf("l : type %-7T value %d\n", l, l)

    
    
    
    m := 0.3 + float64(l) + 0.7
    fmt.Printf("m : type %-7T value %g\n", m, m)
}
Task: Implicit type conversion
C++: #include <iostream>
#include <math.h>

struct PolarPoint;


struct CartesianPoint
{
    double x;
    double y;
    
    
    operator PolarPoint();
};


struct PolarPoint
{
    double rho;
    double theta;
    
    
    operator CartesianPoint();
};


CartesianPoint::operator PolarPoint()
{
    return PolarPoint
    {
        sqrt(x*x + y*y),
        atan2(y, x)
    };
}


PolarPoint::operator CartesianPoint()
{
    return CartesianPoint 
    {
        rho * cos(theta),
        rho * sin(theta)
    };
}

int main()
{
    
    CartesianPoint cp1{2,-2};
    
    PolarPoint pp1 = cp1;
    
    CartesianPoint cp2 = pp1;
    
    std::cout << "rho=" << pp1.rho << ", theta=" << pp1.theta << "\n"; 
    std::cout << "x=" << cp2.x << ", y=" << cp2.y << "\n"; 
}

Java: public class ImplicitTypeConversion{
   public static void main(String...args){
      System.out.println( "Primitive conversions" );
      byte  by = -1;
      short sh = by;
      int   in = sh;
      long  lo = in;
      System.out.println( "byte value    -1         to 3 integral types:  " + lo );

      float  fl = 0.1f;
      double db = fl;
      System.out.println( "float value   0.1        to double:            " + db );

      int    in2 = -1;
      float  fl2 = in2;
      double db2 = fl2;
      System.out.println( "int value     -1         to float and double:  " + db2 );

      int    in3 = Integer.MAX_VALUE;
      float  fl3 = in3;
      double db3 = fl3;
      System.out.println( "int value     " + Integer.MAX_VALUE + " to float and double:  " + db3 );

      char   ch  = 'a';
      int    in4 = ch;
      double db4 = in4;
      System.out.println( "char value    '" + ch + "'        to int and double:    " + db4 );

      System.out.println();
      System.out.println( "Boxing and unboxing" );
      Integer in5 = -1;
      int     in6 = in5;
      System.out.println( "int  value    -1         to Integer and int:   " + in6 );

      Double db5 = 0.1;
      double db6 = db5;
      System.out.println( "double value  0.1        to Double and double: " + db6 );
   }
}
Task: Implicit type conversion
C++: #include <iostream>
#include <math.h>

struct PolarPoint;


struct CartesianPoint
{
    double x;
    double y;
    
    
    operator PolarPoint();
};


struct PolarPoint
{
    double rho;
    double theta;
    
    
    operator CartesianPoint();
};


CartesianPoint::operator PolarPoint()
{
    return PolarPoint
    {
        sqrt(x*x + y*y),
        atan2(y, x)
    };
}


PolarPoint::operator CartesianPoint()
{
    return CartesianPoint 
    {
        rho * cos(theta),
        rho * sin(theta)
    };
}

int main()
{
    
    CartesianPoint cp1{2,-2};
    
    PolarPoint pp1 = cp1;
    
    CartesianPoint cp2 = pp1;
    
    std::cout << "rho=" << pp1.rho << ", theta=" << pp1.theta << "\n"; 
    std::cout << "x=" << cp2.x << ", y=" << cp2.y << "\n"; 
}

Python: from fractions import Fraction
from decimal import Decimal, getcontext
getcontext().prec = 60
from itertools import product

casting_functions = [int, float, complex,   
                     Fraction, Decimal,     
                     hex, oct, bin,         
                     bool,                  
                     iter,                  
                     list, tuple, range,    
                     str, bytes,            
                     bytearray,             
                     set, frozenset,        
                     dict,                  
                    ]

examples_of_types = [0, 42, 
                     0.0 -0.0, 12.34, 56.0, 
                     (0+0j), (1+2j), (1+0j), (78.9+0j), (0+1.2j),
                     Fraction(0, 1), Fraction(22, 7), Fraction(4, 2), 
                     Decimal('0'),
                     Decimal('3.14159265358979323846264338327950288419716939937510'),
                     Decimal('1'), Decimal('1.5'),
                     True, False,
                     iter(()), iter([1, 2, 3]), iter({'A', 'B', 'C'}), 
                     iter([[1, 2], [3, 4]]), iter((('a', 1), (2, 'b'))),
                     [], [1, 2], [[1, 2], [3, 4]],
                     (), (1, 'two', (3+0j)), (('a', 1), (2, 'b')),
                     range(0), range(3),
                     "", "A", "ABBA", "Milü",
                     b"", b"A", b"ABBA",
                     bytearray(b""), bytearray(b"A"), bytearray(b"ABBA"),
                     set(), {1, 'two', (3+0j), (4, 5, 6)},
                     frozenset(), frozenset({1, 'two', (3+0j), (4, 5, 6)}),
                     {}, {1: 'one', 'two': (2+3j), ('RC', 3): None} 
                    ]
if __name__ == '__main__':
    print('Common Python types/type casting functions:')
    print('  ' + '\n  '.join(f.__name__ for f in casting_functions))
    print('\nExamples of those types:')
    print('  ' + '\n  '.join('%-26s %r' % (type(e), e) for e in examples_of_types))
    print('\nCasts of the examples:')
    for f, e in product(casting_functions, examples_of_types):
        try:
            ans = f(e)
        except BaseException:
            ans = 'EXCEPTION RAISED!'
        print('%-60s -> %r' % ('%s(%r)' % (f.__name__, e), ans))
Task: Implicit type conversion
C#: byte aByte = 2;
short aShort = aByte;
int anInt = aShort;
long aLong = anInt;

float aFloat = 1.2f;
double aDouble = aFloat;

BigInteger b = 5;
Complex c = 2.5; 

Go: package main

import "fmt"

func main() {
    

    
    
    var i int32 = 1
    fmt.Printf("i : type %-7T value %d\n", i, i)

    
    
    
    j := 2
    fmt.Printf("j : type %-7T value %d\n", j, j)

    
    
    
    
    var k int64 = int64(i) + int64(j)
    fmt.Printf("k : type %-7T value %d\n", k, k)

    
    
    

    
    
    
    var l int8 = 4.0
    fmt.Printf("l : type %-7T value %d\n", l, l)

    
    
    
    m := 0.3 + float64(l) + 0.7
    fmt.Printf("m : type %-7T value %g\n", m, m)
}
Task: Implicit type conversion
C#: byte aByte = 2;
short aShort = aByte;
int anInt = aShort;
long aLong = anInt;

float aFloat = 1.2f;
double aDouble = aFloat;

BigInteger b = 5;
Complex c = 2.5; 

Java: public class ImplicitTypeConversion{
   public static void main(String...args){
      System.out.println( "Primitive conversions" );
      byte  by = -1;
      short sh = by;
      int   in = sh;
      long  lo = in;
      System.out.println( "byte value    -1         to 3 integral types:  " + lo );

      float  fl = 0.1f;
      double db = fl;
      System.out.println( "float value   0.1        to double:            " + db );

      int    in2 = -1;
      float  fl2 = in2;
      double db2 = fl2;
      System.out.println( "int value     -1         to float and double:  " + db2 );

      int    in3 = Integer.MAX_VALUE;
      float  fl3 = in3;
      double db3 = fl3;
      System.out.println( "int value     " + Integer.MAX_VALUE + " to float and double:  " + db3 );

      char   ch  = 'a';
      int    in4 = ch;
      double db4 = in4;
      System.out.println( "char value    '" + ch + "'        to int and double:    " + db4 );

      System.out.println();
      System.out.println( "Boxing and unboxing" );
      Integer in5 = -1;
      int     in6 = in5;
      System.out.println( "int  value    -1         to Integer and int:   " + in6 );

      Double db5 = 0.1;
      double db6 = db5;
      System.out.println( "double value  0.1        to Double and double: " + db6 );
   }
}