H I O X INDIA
FREE Javascript
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java Script Source
List All
Date & Time
Calendar
Stop Watch script
Slide Show
Image Effect
Mouse Effects
Color Picker Tool
Dynamic Color
Random Generator
Select All
Form Validation
Textbox Counter
Dynamic Form select
Bookmark
Window / User Info
Security / Authenticate
Status Bar
Title Bar
Cursor Position
Country List
Calculators
Delete Repeated Values
Alphanumeric
Free Games





Javascript-Decimal to Binary conversion


About
Javascript decimal number to binary value conversion is used to calculate binary value for a given decimal number.


Features
a) You can convert decimal number to binary value using this javascript.
b) Just copy the code and use it.


Preview
Enter decimal number to convert it to binary value

Decimal Number:

Binary Number:   


Code
  Javascript Code
<!-- Script by hscripts.com -->
<script language=javascript> function isNum(args) { args = args.toString(); if (args.length == 0) return false; for (var i = 0;i<args.length;i++) { if (args.substring(i,i+1) < "0" || args.substring(i, i+1) > "9") { return false; } } return true; } function deciToBin(arg) { res1 = 999; args = arg; while(args>1) { arg1 = parseInt(args/2); arg2 = args%2; args = arg1; if(res1 == 999) { res1 = arg2.toString(); } else { res1 = arg2.toString()+res1.toString(); } } if(args == 1 && res1 != 999) { res1 = args.toString()+res1.toString(); } else if(args == 0 && res1 == 999) { res1 = 0; } else if(res1 == 999) { res1 = 1; } var ll = res1.length; while(ll%4 != 0) { res1 = "0"+res1; ll = res1.length; } return res1; } function change(name) { var sd = name.value; if(isNum(sd)) { var result = deciToBin(sd); document.first.deciBin.value = result; } else { document.first.deci.value = sd.substring(0,sd.length-1) ; } } </script>
<!-- Script by hscripts.com -->


Get free version without ©copyright link for just 5



Usage
Here we have explained with a form

a) Copy the HTML code given below to create form
<form name=first>
Decimal Number: <input name=deci type="text" onkeyup="change(this)" size=20>
Binary Number: <input name=deciBin type="text" size=20 readonly class=resform>
</form>


b) Copy the above Javascript code into your page and use it.

c) If decimal number is entered in the textbox, The javascript function "change()" is converts the given value into binary number.




License
- This javascript (misspelled as java script)/HTML code is given under GPL License
- i.e. Free use for those who use it as it is.
- Free, if your modification does not remove our copyright information and links.
- Detailed License information can be found here
- You can purchase the script if your requirements does not meet GPL License terms.


privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Others