A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11337 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5828 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.


Random Links | Add your own Flash Related Links
Flash Tutorials 1280 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make a Flash Slide Show Screen Saver
» Simple flash making tutorial for thanksgiving
» Create flash banner for website
» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» Unknown Tag: Title10
Random Tutorial | Add Site

Trading Customer Accounting (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Math-Physics

Categories Conversion of Number Systems
Author: Mr.Ehab

 
Page 4
«prev 1 2 3 4 5 6 7 next»

FUNCTION SCRIPTS

1) The script of Function decimalToHexadecimal is:
function decimalToHexadecimal (number) {
 array5.splice(0);
 array4.splice(0);
 for (i = 0; i <= number; i ++) {
 binary = Math.pow (16, i);
 if (binary> number) {
 arrayelement = i - 1;
 break;
 }
 array5 [i] = binary;
 }
 for (j = arrayelement; j>= 0; j --) {
 if (j == arrayelement) {
 binaryelement = int (number / array5 [j]);
 binaryremainder = int (number % array5 [j]);
 if (binaryelement == 10) {
 binaryelement2 = 'A';
 } else if (binaryelement == 11) {
 binaryelement2 = 'B';
 } else if (binaryelement == 12) {
 binaryelement2 = 'C';
 } else if (binaryelement == 13) {
 binaryelement2 = 'D';
 } else if (binaryelement == 14) {
 binaryelement2 = 'E';
 } else if (binaryelement == 15) {
 binaryelement2 = 'F';
 } else {
 binaryelement2 = binaryelement;
 }
 array4 [ 0 ] = binaryelement2;
 } else {
 binaryremainder1 = binaryremainder;
 binaryremainder = int (binaryremainder % array5 [j]);
 binaryelement = int (binaryremainder1 / array5 [j]);
 if (binaryelement == 10) {
 binaryelement2 = 'A';
 } else if (binaryelement == 11) {
 binaryelement2 = 'B';
 } else if (binaryelement == 12) {
 binaryelement2 = 'C';
 } else if (binaryelement == 13) {
 binaryelement2 = 'D';
 } else if (binaryelement == 14) {
 binaryelement2 = 'E';
 } else if (binaryelement == 15) {
 binaryelement2 = 'F';
 } else {
 binaryelement2 = binaryelement;
 }
 array4 [arrayelement - j] = binaryelement2;
 }
 }
 return array4.join ("");
}

Explanation line by line:
1. Function header that takes one argument, which is the number the user types in the input variable.
2. Deletes all elements of array5
3. Deletes all elements of array6
4. A for repetition structure which executes (number + 1) times and initializes variable i to zero. The aim of this for structure is to initialize the elements of array5. The elements of this array are simply the powers of 16 that are assigned to the variable binary.
5. The if selection structure that tests whether binary is greater than number.
6. arrayelement is the variable that tells us the number of valid values of binary which corresponds to the position number or subscript of the last element in array5. When binary is greater than number, i must not be the subscript of the last element and hence is decremented by 1 and assigned to arrayelement.
7. The purpose of this Break statement is to terminate the for structure when binary is greater than number.
8. The statement that initializes array5.
9. A for repetition structure that uses a variable j whose initial value is arrayelement and is continuously decremented per loop.
10. If selection structure that tests if j is equal to arrayelement.
11. Divides our number by the last element in the array and truncates the decimal part by converting it to integer and assigns the last value to variable binaryelement.
12. Same as above but by finding the remainder using the modulus operator and assigning the last value to variable binaryremainder.
13. If selection structure that tests whether binaryelement is 10 or not.
14. sets binaryelement2 to be equal to character A. Same explanation for lines 15 till 24
25. If binaryelement is neither 10, 11, 12, 13, 14, 15, set binaryelement2 to be equal to binaryelement.
26. Initializes the first element of array4 to binaryelement2. The elements of this array are the digits of the hexadecimal number.
27. Else structure corresponding to if.
28. Initializes binaryremainder1 to be equal to binaryremainder.
29. Replaces the value of binaryremainder by another value that is equal to the remainder of dividing binaryremainder by a certain element of array5.
30. Replaces the value of binaryelement by another value which is equal to the quotient of dividing binaryremainder1 by a certain element of array5.
Same explanation for lines 31 till 44 as for 14 till 25.
45. Initializes an element of array4 to be equal to binaryelement2. Notice that this array may hold string characters.
46. Displays the elements of the array in the output without being separated.

Although this may sound quite big, but it's just the same as the method I explained in the beginning of the tutorial.

«prev 1 2 3 4 5 6 7 next»

» Level Intermediate

Added: : 2002-03-04
Rating: 6.83 Votes: 19
Hits: 1094
» Author
Student studying Computer Engineering and Graphic Design.
» Download
Download the files used in this tutorial.
Download (34 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs