![]() The code you have already writes 1 byte to disk whose bit sequence is 10000000 you're already doing it, your code is fine as is. Or any other app that knows that it is to be interpreted as a signed 2's complement byte. If I have the number -128 and I want to write it to disk, presumably you just write the bit sequence 10000000 to disk and, yup, that doesn't mean anything unless the user of the computer opens that file again with your app. How would I exactly convert this from an unsigned byte to signed bytes before it gets placed into output.write and evaluated by. The exact same principle (it's not the byte itself, it's the software or human eyeballs that decide what it means) applies in reverse as well: If I want to 'write' Unchained Melody to disk, it's the software that decides how to do it. Same bytes in either case - it's the app that reads them that causes those exact same bytes to mean something completely different. I can make you a file which, if you name it 'foo.zip' and unzip it produces 1 file with the collected works of shakespeare in plain text inside. Given a file containing just 1 byte, with bitsequence 10000000 (which is just a sequence of bytes, no metadata), you have no idea which of the above interpretation is correct. Nothing appears on screen, instead, the dulcet tones of Unchained Melody blast out of the speaker (interpretation: It's an id of a song, and Unchained Melody's ID is bit sequence 10000000).-127 (interpretation: It's a 1s complement signed byte, show in decimal).The 128th item in the unicode table is 'control', and not really a character perse). � (interpretation: It's a unicode character.-80 (interpretation: Show in hex, signed).80 (interpretation: Show it in hexadecimal, unsigned).-128 (interpretation: It's a 2s complement signed byte, show in decimal).128 (interpretation: It's an unsigned byte, show it in decimal).Perhaps you have some software that reads this byte and shows the value of it on screen.ĭepending on which software you use, you might see any of the following and they are all equally correct: Let's make it more interesting and work with the byte 10000000. Is that signed? The byte has no idea - the software (or the human eyeballs) that look at it decide whether it is or not. It's things that interact with the byte that decide how one is to read it. What does 01001100 mean? Is that signed or unsigned? The byte doesn't know. You seem to misunderstand how computers work.Ī byte is what it is.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |