際際滷

際際滷Share a Scribd company logo
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mylabs;
/**
*
* @author x86 a.k.a haripinter
*/
public class decimal {
public static void main(String[] haripinter){
int des = 1000;
// desimal ke biner
String bin = Integer.toBinaryString(des);
System.out.println(bin);
// desimal ke hexa
String hex = Integer.toHexString(des);
System.out.println(hex);
// biner ke desimal
int des1 = Integer.valueOf(bin,2);
System.out.println(des1);
// biner ke desimal
int des2 = Integer.valueOf(hex,16);
System.out.println(des2);
// hexa ke biner
String bin2 = Integer.toBinaryString(Integer.valueOf(hex, 16));
System.out.println(bin2);
// biner ke hexa
String hex2 = Integer.toHexString(Integer.valueOf(bin, 2));
System.out.println(hex2);
}
}
Source Code dalam PHP
KOnversi Bilangan dengan PHP
PHP
<?php
/**
*
* @author x86 a.k.a haripinter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
*
* @author x86 a.k.a haripinter
*/
function cetak($string,$pos){
echo $string.$pos;
}
// desimal ke biner
$des = 1000;
$bin = base_convert($des,10,2);
//atau
$bin2 = decbin($des);
cetak($bin." atau ".$bin2,"n");
// desimal ke hexa
$hex = base_convert($des,10,16);
//atau
$hex2 = dechex($des);
cetak($hex." atau ".$hex2,"n");
// biner ke desimal
$des2 = base_convert($bin,2,10);
//atau
$des3 = bindec($bin);
cetak($des2." atau ".$des3,"n");
// hexa ke desimal
$des4 = base_convert($hex,16,10);
//atau
$des5 = hexdec($bin);
cetak($des4." atau ".$des5,"n");
// hexa ke biner
$bin2 = base_convert($hex,16,2);
cetak($bin2,"n");
// biner ke hexa
$hex2 = base_convert($bin,2,16);
cetak($hex2,"n");
?>

More Related Content

Convert bilangan

  • 1. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package mylabs; /** * * @author x86 a.k.a haripinter */ public class decimal { public static void main(String[] haripinter){ int des = 1000; // desimal ke biner String bin = Integer.toBinaryString(des); System.out.println(bin); // desimal ke hexa String hex = Integer.toHexString(des); System.out.println(hex); // biner ke desimal int des1 = Integer.valueOf(bin,2); System.out.println(des1); // biner ke desimal int des2 = Integer.valueOf(hex,16); System.out.println(des2); // hexa ke biner String bin2 = Integer.toBinaryString(Integer.valueOf(hex, 16)); System.out.println(bin2); // biner ke hexa String hex2 = Integer.toHexString(Integer.valueOf(bin, 2)); System.out.println(hex2); } } Source Code dalam PHP KOnversi Bilangan dengan PHP PHP <?php /** * * @author x86 a.k.a haripinter
  • 2. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 <?php /** * * @author x86 a.k.a haripinter */ function cetak($string,$pos){ echo $string.$pos; } // desimal ke biner $des = 1000; $bin = base_convert($des,10,2); //atau $bin2 = decbin($des); cetak($bin." atau ".$bin2,"n"); // desimal ke hexa $hex = base_convert($des,10,16); //atau $hex2 = dechex($des); cetak($hex." atau ".$hex2,"n"); // biner ke desimal $des2 = base_convert($bin,2,10); //atau $des3 = bindec($bin); cetak($des2." atau ".$des3,"n"); // hexa ke desimal $des4 = base_convert($hex,16,10); //atau $des5 = hexdec($bin); cetak($des4." atau ".$des5,"n"); // hexa ke biner $bin2 = base_convert($hex,16,2); cetak($bin2,"n"); // biner ke hexa $hex2 = base_convert($bin,2,16); cetak($hex2,"n"); ?>