WeixiangYan/CodeTransOcean huggingface dataset:
Task: Call a function in a shared library

C: #include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int myopenimage(const char *in)
{
  static int handle=0;
  fprintf(stderr, "internal openimage opens %s...\n", in);
  return handle++;
}

int main()
{
  void *imglib;
  int (*extopenimage)(const char *);
  int imghandle;

  imglib = dlopen("./fakeimglib.so", RTLD_LAZY);
  if ( imglib != NULL ) {
    
    *(void **)(&extopenimage) = dlsym(imglib, "openimage");
    
    
    imghandle = extopenimage("fake.img");
  } else {
    imghandle = myopenimage("fake.img");
  }
  printf("opened with handle %d\n", imghandle);
  
  if (imglib != NULL ) dlclose(imglib);
  return EXIT_SUCCESS;
}



C#: using System.Runtime.InteropServices;

class Program {
    [DllImport("fakelib.dll")]
    public static extern int fakefunction(int args);

    static void Main(string[] args) {
        int r = fakefunction(10);
    }
}
Task: Call a function in a shared library



C#: using System.Runtime.InteropServices;

class Program {
    [DllImport("fakelib.dll")]
    public static extern int fakefunction(int args);

    static void Main(string[] args) {
        int r = fakefunction(10);
    }
}


Go: package main


import "C"
import (
    "fmt"
    "os"
    "unsafe"
)

var handle = -1

func myOpenImage(s string) int {
    fmt.Fprintf(os.Stderr, "internal openImage opens %s...\n", s)
    handle++
    return handle
}

func main() {
    libpath := C.CString("./fakeimglib.so")
    defer C.free(unsafe.Pointer(libpath))
    imglib := C.dlopen(libpath, C.RTLD_LAZY)
    var imghandle int
    if imglib != nil {
        openimage := C.CString("openimage")
        defer C.free(unsafe.Pointer(openimage))
        fp := C.dlsym(imglib, openimage)
        if fp != nil {
            fi := C.CString("fake.img")
            defer C.free(unsafe.Pointer(fi))
            imghandle = int(C.bridge_someFunc(C.someFunc(fp), fi))

        } else {
            imghandle = myOpenImage("fake.img")
        }
        C.dlclose(imglib)
    } else {
        imghandle = myOpenImage("fake.img")
    }
    fmt.Printf("opened with handle %d\n", imghandle)
}
Task: Call a function in a shared library



C#: using System.Runtime.InteropServices;

class Program {
    [DllImport("fakelib.dll")]
    public static extern int fakefunction(int args);

    static void Main(string[] args) {
        int r = fakefunction(10);
    }
}





Python: import ctypes
  
user32_dll = ctypes.cdll.LoadLibrary('User32.dll')
print user32_dll.GetDoubleClickTime()
Task: Call a function in a shared library



C#: using System.Runtime.InteropServices;

class Program {
    [DllImport("fakelib.dll")]
    public static extern int fakefunction(int args);

    static void Main(string[] args) {
        int r = fakefunction(10);
    }
}






VB: Declare Dynamic Library "Kernel32"
    Sub SetLastError (ByVal dwErr As Long)
    Function GetLastError& ()
End Declare

SetLastError 20
Print GetLastError
Task: Call a function in a shared library





Java: 

import java.util.Collections;
import java.util.Random;

public class TrySort {
    static boolean useC;
    static {
	try {
	    System.loadLibrary("TrySort");
	    useC = true;
	} catch(UnsatisfiedLinkError e) {
	    useC = false;
	}
    }
    
    static native void sortInC(int[] ary);
    
    static class IntList extends java.util.AbstractList<Integer> {
	int[] ary;
	IntList(int[] ary) { this.ary = ary; }
	public Integer get(int i) { return ary[i]; }
	public Integer set(int i, Integer j) {
	    Integer o = ary[i]; ary[i] = j; return o;
	}
	public int size() { return ary.length; }
    }

    static class ReverseAbsCmp
	implements java.util.Comparator<Integer>
    {
	public int compare(Integer pa, Integer pb) {
	    
	    int a = pa > 0 ? -pa : pa;
	    int b = pb > 0 ? -pb : pb;
	    return a < b ? -1 : a > b ? 1 : 0;
	}
    }
    
    static void sortInJava(int[] ary) {
	Collections.sort(new IntList(ary), new ReverseAbsCmp());
    }

    public static void main(String[] args) {
	
	int[] ary = new int[1000000];
	Random rng = new Random();
	for (int i = 0; i < ary.length; i++)
	    ary[i] = rng.nextInt();

	
	if (useC) {
	    System.out.print("Sorting in C...  ");
	    sortInC(ary);
	} else {
	    System.out.print
		("Missing library for C!  Sorting in Java...  ");
	    sortInJava(ary);
	}

	for (int i = 0; i < ary.length - 1; i++) {
	    int a = ary[i];
	    int b = ary[i + 1];
	    if ((a > 0 ? -a : a) > (b > 0 ? -b : b)) {
		System.out.println("*BUG IN SORT*");
		System.exit(1);
	    }
	}
	System.out.println("ok");
    }
}



Python: import ctypes
  
user32_dll = ctypes.cdll.LoadLibrary('User32.dll')
print user32_dll.GetDoubleClickTime()
Task: Call a function in a shared library





Java: 

import java.util.Collections;
import java.util.Random;

public class TrySort {
    static boolean useC;
    static {
	try {
	    System.loadLibrary("TrySort");
	    useC = true;
	} catch(UnsatisfiedLinkError e) {
	    useC = false;
	}
    }
    
    static native void sortInC(int[] ary);
    
    static class IntList extends java.util.AbstractList<Integer> {
	int[] ary;
	IntList(int[] ary) { this.ary = ary; }
	public Integer get(int i) { return ary[i]; }
	public Integer set(int i, Integer j) {
	    Integer o = ary[i]; ary[i] = j; return o;
	}
	public int size() { return ary.length; }
    }

    static class ReverseAbsCmp
	implements java.util.Comparator<Integer>
    {
	public int compare(Integer pa, Integer pb) {
	    
	    int a = pa > 0 ? -pa : pa;
	    int b = pb > 0 ? -pb : pb;
	    return a < b ? -1 : a > b ? 1 : 0;
	}
    }
    
    static void sortInJava(int[] ary) {
	Collections.sort(new IntList(ary), new ReverseAbsCmp());
    }

    public static void main(String[] args) {
	
	int[] ary = new int[1000000];
	Random rng = new Random();
	for (int i = 0; i < ary.length; i++)
	    ary[i] = rng.nextInt();

	
	if (useC) {
	    System.out.print("Sorting in C...  ");
	    sortInC(ary);
	} else {
	    System.out.print
		("Missing library for C!  Sorting in Java...  ");
	    sortInJava(ary);
	}

	for (int i = 0; i < ary.length - 1; i++) {
	    int a = ary[i];
	    int b = ary[i + 1];
	    if ((a > 0 ? -a : a) > (b > 0 ? -b : b)) {
		System.out.println("*BUG IN SORT*");
		System.exit(1);
	    }
	}
	System.out.println("ok");
    }
}




VB: Declare Dynamic Library "Kernel32"
    Sub SetLastError (ByVal dwErr As Long)
    Function GetLastError& ()
End Declare

SetLastError 20
Print GetLastError
Task: Call a function in a shared library




Go: package main


import "C"
import (
    "fmt"
    "os"
    "unsafe"
)

var handle = -1

func myOpenImage(s string) int {
    fmt.Fprintf(os.Stderr, "internal openImage opens %s...\n", s)
    handle++
    return handle
}

func main() {
    libpath := C.CString("./fakeimglib.so")
    defer C.free(unsafe.Pointer(libpath))
    imglib := C.dlopen(libpath, C.RTLD_LAZY)
    var imghandle int
    if imglib != nil {
        openimage := C.CString("openimage")
        defer C.free(unsafe.Pointer(openimage))
        fp := C.dlsym(imglib, openimage)
        if fp != nil {
            fi := C.CString("fake.img")
            defer C.free(unsafe.Pointer(fi))
            imghandle = int(C.bridge_someFunc(C.someFunc(fp), fi))

        } else {
            imghandle = myOpenImage("fake.img")
        }
        C.dlclose(imglib)
    } else {
        imghandle = myOpenImage("fake.img")
    }
    fmt.Printf("opened with handle %d\n", imghandle)
}




Python: import ctypes
  
user32_dll = ctypes.cdll.LoadLibrary('User32.dll')
print user32_dll.GetDoubleClickTime()
Task: Call a function in a shared library




Go: package main


import "C"
import (
    "fmt"
    "os"
    "unsafe"
)

var handle = -1

func myOpenImage(s string) int {
    fmt.Fprintf(os.Stderr, "internal openImage opens %s...\n", s)
    handle++
    return handle
}

func main() {
    libpath := C.CString("./fakeimglib.so")
    defer C.free(unsafe.Pointer(libpath))
    imglib := C.dlopen(libpath, C.RTLD_LAZY)
    var imghandle int
    if imglib != nil {
        openimage := C.CString("openimage")
        defer C.free(unsafe.Pointer(openimage))
        fp := C.dlsym(imglib, openimage)
        if fp != nil {
            fi := C.CString("fake.img")
            defer C.free(unsafe.Pointer(fi))
            imghandle = int(C.bridge_someFunc(C.someFunc(fp), fi))

        } else {
            imghandle = myOpenImage("fake.img")
        }
        C.dlclose(imglib)
    } else {
        imghandle = myOpenImage("fake.img")
    }
    fmt.Printf("opened with handle %d\n", imghandle)
}





VB: Declare Dynamic Library "Kernel32"
    Sub SetLastError (ByVal dwErr As Long)
    Function GetLastError& ()
End Declare

SetLastError 20
Print GetLastError
Task: Call a function in a shared library







Python: import ctypes
  
user32_dll = ctypes.cdll.LoadLibrary('User32.dll')
print user32_dll.GetDoubleClickTime()


VB: Declare Dynamic Library "Kernel32"
    Sub SetLastError (ByVal dwErr As Long)
    Function GetLastError& ()
End Declare

SetLastError 20
Print GetLastError
Task: Call a function in a shared library

C: #include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int myopenimage(const char *in)
{
  static int handle=0;
  fprintf(stderr, "internal openimage opens %s...\n", in);
  return handle++;
}

int main()
{
  void *imglib;
  int (*extopenimage)(const char *);
  int imghandle;

  imglib = dlopen("./fakeimglib.so", RTLD_LAZY);
  if ( imglib != NULL ) {
    
    *(void **)(&extopenimage) = dlsym(imglib, "openimage");
    
    
    imghandle = extopenimage("fake.img");
  } else {
    imghandle = myopenimage("fake.img");
  }
  printf("opened with handle %d\n", imghandle);
  
  if (imglib != NULL ) dlclose(imglib);
  return EXIT_SUCCESS;
}





Java: 

import java.util.Collections;
import java.util.Random;

public class TrySort {
    static boolean useC;
    static {
	try {
	    System.loadLibrary("TrySort");
	    useC = true;
	} catch(UnsatisfiedLinkError e) {
	    useC = false;
	}
    }
    
    static native void sortInC(int[] ary);
    
    static class IntList extends java.util.AbstractList<Integer> {
	int[] ary;
	IntList(int[] ary) { this.ary = ary; }
	public Integer get(int i) { return ary[i]; }
	public Integer set(int i, Integer j) {
	    Integer o = ary[i]; ary[i] = j; return o;
	}
	public int size() { return ary.length; }
    }

    static class ReverseAbsCmp
	implements java.util.Comparator<Integer>
    {
	public int compare(Integer pa, Integer pb) {
	    
	    int a = pa > 0 ? -pa : pa;
	    int b = pb > 0 ? -pb : pb;
	    return a < b ? -1 : a > b ? 1 : 0;
	}
    }
    
    static void sortInJava(int[] ary) {
	Collections.sort(new IntList(ary), new ReverseAbsCmp());
    }

    public static void main(String[] args) {
	
	int[] ary = new int[1000000];
	Random rng = new Random();
	for (int i = 0; i < ary.length; i++)
	    ary[i] = rng.nextInt();

	
	if (useC) {
	    System.out.print("Sorting in C...  ");
	    sortInC(ary);
	} else {
	    System.out.print
		("Missing library for C!  Sorting in Java...  ");
	    sortInJava(ary);
	}

	for (int i = 0; i < ary.length - 1; i++) {
	    int a = ary[i];
	    int b = ary[i + 1];
	    if ((a > 0 ? -a : a) > (b > 0 ? -b : b)) {
		System.out.println("*BUG IN SORT*");
		System.exit(1);
	    }
	}
	System.out.println("ok");
    }
}
Task: Call a function in a shared library

C: #include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int myopenimage(const char *in)
{
  static int handle=0;
  fprintf(stderr, "internal openimage opens %s...\n", in);
  return handle++;
}

int main()
{
  void *imglib;
  int (*extopenimage)(const char *);
  int imghandle;

  imglib = dlopen("./fakeimglib.so", RTLD_LAZY);
  if ( imglib != NULL ) {
    
    *(void **)(&extopenimage) = dlsym(imglib, "openimage");
    
    
    imghandle = extopenimage("fake.img");
  } else {
    imghandle = myopenimage("fake.img");
  }
  printf("opened with handle %d\n", imghandle);
  
  if (imglib != NULL ) dlclose(imglib);
  return EXIT_SUCCESS;
}







Python: import ctypes
  
user32_dll = ctypes.cdll.LoadLibrary('User32.dll')
print user32_dll.GetDoubleClickTime()
Task: Call a function in a shared library

C: #include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int myopenimage(const char *in)
{
  static int handle=0;
  fprintf(stderr, "internal openimage opens %s...\n", in);
  return handle++;
}

int main()
{
  void *imglib;
  int (*extopenimage)(const char *);
  int imghandle;

  imglib = dlopen("./fakeimglib.so", RTLD_LAZY);
  if ( imglib != NULL ) {
    
    *(void **)(&extopenimage) = dlsym(imglib, "openimage");
    
    
    imghandle = extopenimage("fake.img");
  } else {
    imghandle = myopenimage("fake.img");
  }
  printf("opened with handle %d\n", imghandle);
  
  if (imglib != NULL ) dlclose(imglib);
  return EXIT_SUCCESS;
}








VB: Declare Dynamic Library "Kernel32"
    Sub SetLastError (ByVal dwErr As Long)
    Function GetLastError& ()
End Declare

SetLastError 20
Print GetLastError
Task: Call a function in a shared library



C#: using System.Runtime.InteropServices;

class Program {
    [DllImport("fakelib.dll")]
    public static extern int fakefunction(int args);

    static void Main(string[] args) {
        int r = fakefunction(10);
    }
}



Java: 

import java.util.Collections;
import java.util.Random;

public class TrySort {
    static boolean useC;
    static {
	try {
	    System.loadLibrary("TrySort");
	    useC = true;
	} catch(UnsatisfiedLinkError e) {
	    useC = false;
	}
    }
    
    static native void sortInC(int[] ary);
    
    static class IntList extends java.util.AbstractList<Integer> {
	int[] ary;
	IntList(int[] ary) { this.ary = ary; }
	public Integer get(int i) { return ary[i]; }
	public Integer set(int i, Integer j) {
	    Integer o = ary[i]; ary[i] = j; return o;
	}
	public int size() { return ary.length; }
    }

    static class ReverseAbsCmp
	implements java.util.Comparator<Integer>
    {
	public int compare(Integer pa, Integer pb) {
	    
	    int a = pa > 0 ? -pa : pa;
	    int b = pb > 0 ? -pb : pb;
	    return a < b ? -1 : a > b ? 1 : 0;
	}
    }
    
    static void sortInJava(int[] ary) {
	Collections.sort(new IntList(ary), new ReverseAbsCmp());
    }

    public static void main(String[] args) {
	
	int[] ary = new int[1000000];
	Random rng = new Random();
	for (int i = 0; i < ary.length; i++)
	    ary[i] = rng.nextInt();

	
	if (useC) {
	    System.out.print("Sorting in C...  ");
	    sortInC(ary);
	} else {
	    System.out.print
		("Missing library for C!  Sorting in Java...  ");
	    sortInJava(ary);
	}

	for (int i = 0; i < ary.length - 1; i++) {
	    int a = ary[i];
	    int b = ary[i + 1];
	    if ((a > 0 ? -a : a) > (b > 0 ? -b : b)) {
		System.out.println("*BUG IN SORT*");
		System.exit(1);
	    }
	}
	System.out.println("ok");
    }
}
Task: Call a function in a shared library




Go: package main


import "C"
import (
    "fmt"
    "os"
    "unsafe"
)

var handle = -1

func myOpenImage(s string) int {
    fmt.Fprintf(os.Stderr, "internal openImage opens %s...\n", s)
    handle++
    return handle
}

func main() {
    libpath := C.CString("./fakeimglib.so")
    defer C.free(unsafe.Pointer(libpath))
    imglib := C.dlopen(libpath, C.RTLD_LAZY)
    var imghandle int
    if imglib != nil {
        openimage := C.CString("openimage")
        defer C.free(unsafe.Pointer(openimage))
        fp := C.dlsym(imglib, openimage)
        if fp != nil {
            fi := C.CString("fake.img")
            defer C.free(unsafe.Pointer(fi))
            imghandle = int(C.bridge_someFunc(C.someFunc(fp), fi))

        } else {
            imghandle = myOpenImage("fake.img")
        }
        C.dlclose(imglib)
    } else {
        imghandle = myOpenImage("fake.img")
    }
    fmt.Printf("opened with handle %d\n", imghandle)
}


Java: 

import java.util.Collections;
import java.util.Random;

public class TrySort {
    static boolean useC;
    static {
	try {
	    System.loadLibrary("TrySort");
	    useC = true;
	} catch(UnsatisfiedLinkError e) {
	    useC = false;
	}
    }
    
    static native void sortInC(int[] ary);
    
    static class IntList extends java.util.AbstractList<Integer> {
	int[] ary;
	IntList(int[] ary) { this.ary = ary; }
	public Integer get(int i) { return ary[i]; }
	public Integer set(int i, Integer j) {
	    Integer o = ary[i]; ary[i] = j; return o;
	}
	public int size() { return ary.length; }
    }

    static class ReverseAbsCmp
	implements java.util.Comparator<Integer>
    {
	public int compare(Integer pa, Integer pb) {
	    
	    int a = pa > 0 ? -pa : pa;
	    int b = pb > 0 ? -pb : pb;
	    return a < b ? -1 : a > b ? 1 : 0;
	}
    }
    
    static void sortInJava(int[] ary) {
	Collections.sort(new IntList(ary), new ReverseAbsCmp());
    }

    public static void main(String[] args) {
	
	int[] ary = new int[1000000];
	Random rng = new Random();
	for (int i = 0; i < ary.length; i++)
	    ary[i] = rng.nextInt();

	
	if (useC) {
	    System.out.print("Sorting in C...  ");
	    sortInC(ary);
	} else {
	    System.out.print
		("Missing library for C!  Sorting in Java...  ");
	    sortInJava(ary);
	}

	for (int i = 0; i < ary.length - 1; i++) {
	    int a = ary[i];
	    int b = ary[i + 1];
	    if ((a > 0 ? -a : a) > (b > 0 ? -b : b)) {
		System.out.println("*BUG IN SORT*");
		System.exit(1);
	    }
	}
	System.out.println("ok");
    }
}
Task: Call a function in a shared library

C: #include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int myopenimage(const char *in)
{
  static int handle=0;
  fprintf(stderr, "internal openimage opens %s...\n", in);
  return handle++;
}

int main()
{
  void *imglib;
  int (*extopenimage)(const char *);
  int imghandle;

  imglib = dlopen("./fakeimglib.so", RTLD_LAZY);
  if ( imglib != NULL ) {
    
    *(void **)(&extopenimage) = dlsym(imglib, "openimage");
    
    
    imghandle = extopenimage("fake.img");
  } else {
    imghandle = myopenimage("fake.img");
  }
  printf("opened with handle %d\n", imghandle);
  
  if (imglib != NULL ) dlclose(imglib);
  return EXIT_SUCCESS;
}




Go: package main


import "C"
import (
    "fmt"
    "os"
    "unsafe"
)

var handle = -1

func myOpenImage(s string) int {
    fmt.Fprintf(os.Stderr, "internal openImage opens %s...\n", s)
    handle++
    return handle
}

func main() {
    libpath := C.CString("./fakeimglib.so")
    defer C.free(unsafe.Pointer(libpath))
    imglib := C.dlopen(libpath, C.RTLD_LAZY)
    var imghandle int
    if imglib != nil {
        openimage := C.CString("openimage")
        defer C.free(unsafe.Pointer(openimage))
        fp := C.dlsym(imglib, openimage)
        if fp != nil {
            fi := C.CString("fake.img")
            defer C.free(unsafe.Pointer(fi))
            imghandle = int(C.bridge_someFunc(C.someFunc(fp), fi))

        } else {
            imghandle = myOpenImage("fake.img")
        }
        C.dlclose(imglib)
    } else {
        imghandle = myOpenImage("fake.img")
    }
    fmt.Printf("opened with handle %d\n", imghandle)
}
Task: Literals_Integer

C: #include <stdio.h>

int main(void)
{
  printf("%s\n",
         ( (727 == 0x2d7) && 
           (727 == 01327)    ) ? "true" : "false");

  return 0;
}



C#: int a = 42;
int b = 0x2a;
Task: Literals_Integer

C: #include <stdio.h>

int main(void)
{
  printf("%s\n",
         ( (727 == 0x2d7) && 
           (727 == 01327)    ) ? "true" : "false");

  return 0;
}


C++: #include <iostream>

int main()
{
  std::cout << ( (727 == 0x2d7) && 
                 (727 == 01327)     ? "true" : "false")
            << std::endl;
 
  return 0;
}
Task: Literals_Integer

C: #include <stdio.h>

int main(void)
{
  printf("%s\n",
         ( (727 == 0x2d7) && 
           (727 == 01327)    ) ? "true" : "false");

  return 0;
}




Go: package main

import "fmt"

func main() {
	fmt.Println(727 == 0x2d7)         
	fmt.Println(727 == 01327)         
	fmt.Println(727 == 0b10110_10111) 
	fmt.Println(727 == '˗')           
}
Task: Literals_Integer

C: #include <stdio.h>

int main(void)
{
  printf("%s\n",
         ( (727 == 0x2d7) && 
           (727 == 01327)    ) ? "true" : "false");

  return 0;
}





Java: public class IntegerLiterals {
    public static void main(String[] args) {
        System.out.println( 727 == 0x2d7 && 
                            727 == 01327   );
    }
}
Task: Literals_Integer

C: #include <stdio.h>

int main(void)
{
  printf("%s\n",
         ( (727 == 0x2d7) && 
           (727 == 01327)    ) ? "true" : "false");

  return 0;
}







Python: >>> 
>>> 0b1011010111 == 0o1327 == 727 == 0x2d7
True
>>>
Task: Literals_Integer


C++: #include <iostream>

int main()
{
  std::cout << ( (727 == 0x2d7) && 
                 (727 == 01327)     ? "true" : "false")
            << std::endl;
 
  return 0;
}


C#: int a = 42;
int b = 0x2a;
Task: Literals_Integer


C++: #include <iostream>

int main()
{
  std::cout << ( (727 == 0x2d7) && 
                 (727 == 01327)     ? "true" : "false")
            << std::endl;
 
  return 0;
}



Go: package main

import "fmt"

func main() {
	fmt.Println(727 == 0x2d7)         
	fmt.Println(727 == 01327)         
	fmt.Println(727 == 0b10110_10111) 
	fmt.Println(727 == '˗')           
}
Task: Literals_Integer


C++: #include <iostream>

int main()
{
  std::cout << ( (727 == 0x2d7) && 
                 (727 == 01327)     ? "true" : "false")
            << std::endl;
 
  return 0;
}







VB: Sub Main()


Dim l1 As Long, l2 As Long, l3 As Long

Dim i1 As Integer, i2 As Integer, i3 As Integer

Dim b1 As Byte, b2 As Byte, b3 As Byte
  
  l1 = 1024&
  l2 = &H400&
  l3 = &O2000&
  Debug.Assert l1 = l2
  Debug.Assert l2 = l3
  
  i1 = 1024
  i2 = &H400
  i3 = &O2000
  Debug.Assert i1 = i2
  Debug.Assert i2 = i3
  
  b1 = 255
  b2 = &O377
  b3 = &HFF
  Debug.Assert b1 = b2
  Debug.Assert b2 = b3
  
End Sub
Task: Literals_Integer



C#: int a = 42;
int b = 0x2a;


Go: package main

import "fmt"

func main() {
	fmt.Println(727 == 0x2d7)         
	fmt.Println(727 == 01327)         
	fmt.Println(727 == 0b10110_10111) 
	fmt.Println(727 == '˗')           
}
Task: Literals_Integer



C#: int a = 42;
int b = 0x2a;



Java: public class IntegerLiterals {
    public static void main(String[] args) {
        System.out.println( 727 == 0x2d7 && 
                            727 == 01327   );
    }
}
Task: Literals_Integer



C#: int a = 42;
int b = 0x2a;






VB: Sub Main()


Dim l1 As Long, l2 As Long, l3 As Long

Dim i1 As Integer, i2 As Integer, i3 As Integer

Dim b1 As Byte, b2 As Byte, b3 As Byte
  
  l1 = 1024&
  l2 = &H400&
  l3 = &O2000&
  Debug.Assert l1 = l2
  Debug.Assert l2 = l3
  
  i1 = 1024
  i2 = &H400
  i3 = &O2000
  Debug.Assert i1 = i2
  Debug.Assert i2 = i3
  
  b1 = 255
  b2 = &O377
  b3 = &HFF
  Debug.Assert b1 = b2
  Debug.Assert b2 = b3
  
End Sub
Task: Literals_Integer





Java: public class IntegerLiterals {
    public static void main(String[] args) {
        System.out.println( 727 == 0x2d7 && 
                            727 == 01327   );
    }
}



Python: >>> 
>>> 0b1011010111 == 0o1327 == 727 == 0x2d7
True
>>>
Task: Literals_Integer





Java: public class IntegerLiterals {
    public static void main(String[] args) {
        System.out.println( 727 == 0x2d7 && 
                            727 == 01327   );
    }
}




VB: Sub Main()


Dim l1 As Long, l2 As Long, l3 As Long

Dim i1 As Integer, i2 As Integer, i3 As Integer

Dim b1 As Byte, b2 As Byte, b3 As Byte
  
  l1 = 1024&
  l2 = &H400&
  l3 = &O2000&
  Debug.Assert l1 = l2
  Debug.Assert l2 = l3
  
  i1 = 1024
  i2 = &H400
  i3 = &O2000
  Debug.Assert i1 = i2
  Debug.Assert i2 = i3
  
  b1 = 255
  b2 = &O377
  b3 = &HFF
  Debug.Assert b1 = b2
  Debug.Assert b2 = b3
  
End Sub
Task: Literals_Integer




Go: package main

import "fmt"

func main() {
	fmt.Println(727 == 0x2d7)         
	fmt.Println(727 == 01327)         
	fmt.Println(727 == 0b10110_10111) 
	fmt.Println(727 == '˗')           
}




Python: >>> 
>>> 0b1011010111 == 0o1327 == 727 == 0x2d7
True
>>>