<em><html>
<head>
<title > TIPE BILANGAN </title>
</head>
<body bgcolor=red>
<script language = "javascript">
<!--
var a = 20;
b = 14;
tambah = a+b;
kurang = a-b;
kali = a*b;
bagi = a/b;
document.write("penambahan ("+a+"+"+b+")="+ tambah);
document.write("<BR>");
document.write("pengurangan ("+a+"-"+b+")="+ kurang);
document.write("<BR>");
document.write("perkalian ("+a+"x"+b+")="+ kali);
document.write("<BR>");
document.write("pembagian ("+a+"/"+b+")="+ bagi);
document.write("<BR>");
//-->>
</script>
</body>
</html>
</em>
Gbr 01. Hasil dari HTML Tipe Bilangan |
<em>
<html>
<head>
<title > Konversi Antar Sistem Bilangan </title>
</head>
<body bgcolor=green>
<script language = "JavaScript">
<!--
var bil = new Number (25);
document.write("Bilangan Desimal: " +bil+ "<BR>");
document.write(""<HR>"");
document.write("Biner: " +bil. toString (2)+ "<BR>");
document.write("Oktal: " +bil. toString (8)+ "<BR>");
document.write("Heksa: " +bil. toString (16)+ "<BR>");
//-->
</script>
</body>
</html>
</em>
Gbr 02. Hasil dari HTML Knversi Dari Sistem Bilangan |
Latihan III
<em>
<html>
<head>
<title > Jumlah Antar Sistem Bilangan </title>
</head>
<body bgcolor=grey>
<script language = "JavaScript">
<!--
function jumlah (x,y) {
var hasil =x+y;
return (hasil);
}
var a = parseInt (prompt("Ketikan Bilangan A= \n Ingat Jangan String"));
var b = parseInt (prompt("Ketikan Bilangan B= \n Ingat Jangan String"));
var z = jumlah (a,b);
document.write(z);
document.write("<BR>");
document.write("<hr>");
document.write("Tipe Datanya Adalah= " + typeof(z));
//-->
</script>
</body>
</html>
</em>
Gbr 3.1. Masukkan nilai A |
Gbr 3.2 Masukkan Nilai B |
Gbr 3.3 Hasil Penjumlahan Dua Sistem Bilangan |