05-12-2005, 05:41 AM
[note]For Input does not erase file contents. For Output does. For Append does the same thing For Output does except erase file contents.[/note]
Now I'm just going to give a little explainy on binary. Background knowlege is always helpful. So correct me if I'm wrong on anything here:
1byte = 8bits
A bit, sort for binary digit, is a 1 or a 0.
There are 256 ASCII values (0 - 255). In Hex that is (&h00 - &hFF). Since it is soooo easy to convert hex and binary thats what ASCII values do.
Each Hex digit is four binary digits long, so 2 hex digits is 8 bits long so each ASCII caracter is 1 byte long.
Hex|---|Binary
&h0|-|0000
&h1|-|0001
&h2|-|0010
&h3|-|0011
&h4|-|0100
&h5|-|0101
&h6|-|0110
&h7|-|0111
&h8|-|1000
&h9|-|1001
&hA|-|1010
&hB|-|1011
&hC|-|1100
&hD|-|1101
&hE|-|1110
&hF|-|1111
To get a byte value from a character like 'a' you do:
1. Convert to the ASCII decimal value: 'a' = 97
2. Convert it to hex: 97 = &h61
3. Convert each digit to binary: &h6 = 0110 | &h1 = 0001
4. Put the two digits together: 0110|0001
So 01100001 is the binary value of 'a'. The computer stores this value as 01100001 in the memory.
To get a ASCII value from byte then:
1. Get the byte value (lets use 'a' again): 01100001
2. Spilt it up to groups of four: 0110|0001
3. Get the Hex equivalents of it: &h6|&h1
4. Put that number together: &h61
5. Convert it to ASCII decimal: 97
6. Get the character equivalent: 'a'
Yes I know the converting to decimal is optional, but its for human interface more than programmer interface....ummm...ya.
Ok, there u go.
Now I'm just going to give a little explainy on binary. Background knowlege is always helpful. So correct me if I'm wrong on anything here:
1byte = 8bits
A bit, sort for binary digit, is a 1 or a 0.
There are 256 ASCII values (0 - 255). In Hex that is (&h00 - &hFF). Since it is soooo easy to convert hex and binary thats what ASCII values do.
Each Hex digit is four binary digits long, so 2 hex digits is 8 bits long so each ASCII caracter is 1 byte long.
Hex|---|Binary
&h0|-|0000
&h1|-|0001
&h2|-|0010
&h3|-|0011
&h4|-|0100
&h5|-|0101
&h6|-|0110
&h7|-|0111
&h8|-|1000
&h9|-|1001
&hA|-|1010
&hB|-|1011
&hC|-|1100
&hD|-|1101
&hE|-|1110
&hF|-|1111
To get a byte value from a character like 'a' you do:
1. Convert to the ASCII decimal value: 'a' = 97
2. Convert it to hex: 97 = &h61
3. Convert each digit to binary: &h6 = 0110 | &h1 = 0001
4. Put the two digits together: 0110|0001
So 01100001 is the binary value of 'a'. The computer stores this value as 01100001 in the memory.
To get a ASCII value from byte then:
1. Get the byte value (lets use 'a' again): 01100001
2. Spilt it up to groups of four: 0110|0001
3. Get the Hex equivalents of it: &h6|&h1
4. Put that number together: &h61
5. Convert it to ASCII decimal: 97
6. Get the character equivalent: 'a'
Yes I know the converting to decimal is optional, but its for human interface more than programmer interface....ummm...ya.
Ok, there u go.
i]"But...it was so beautifully done"[/i]