summaryrefslogtreecommitdiff
path: root/JS/binary.js
diff options
context:
space:
mode:
authormcd223 <jacob@simplelittledream.com>2019-02-07 19:38:42 -0500
committermcd223 <jacob@simplelittledream.com>2019-02-07 19:38:42 -0500
commit5552ce957b496dd4f0b8447dbfbf8718fbd1f2a7 (patch)
tree50243c695dfb3252fde70254e50087e54044583e /JS/binary.js
redesign 3
Diffstat (limited to 'JS/binary.js')
-rw-r--r--JS/binary.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/JS/binary.js b/JS/binary.js
new file mode 100644
index 0000000..d0b8d21
--- /dev/null
+++ b/JS/binary.js
@@ -0,0 +1,15 @@
+//binary code convertor
+function convertBinary() {
+ var output = document.getElementById("outputBinary");
+ var input = document.getElementById("inputBinary").value;
+ output.value = "";
+ for (i=0; i < input.length; i++) {var e=input[i].charCodeAt(0);var s = "";
+ do{
+ var a =e%2;
+ e=(e-a)/2;
+ s=a+s;
+ }while(e!=0);
+ while(s.length<8){s="0"+s;}
+ output.value+=s;
+ }
+} \ No newline at end of file