File's size as bits?
File's size as bits?
When I see that a file has 1k size does it mean it has 1024*8 bits ?
So if I could see the file as 01010101 I would have seen 8192 bits?
So if I could see the file as 01010101 I would have seen 8192 bits?
Re: File's size as bits?
On both questions the answer is "Yes".MasterGod wrote:When I see that a file has 1k size does it mean it has 1024*8 bits ?
So if I could see the file as 01010101 I would have seen 8192 bits?
The size of any file will always lie on the 8-bit-edge. It means that file can't be 15 or 201 bits long. It can be 0, 8, 16,... 256... bits long. So you never need to know how much bits does file consists of. Quantity of bits will always be filesize()*8.
Another thing that file on the physical disk takes a little bit more space. For example in some cases on FAT file systems any file on disk will occupy the space that will be dividable on 4KB (4096 bytes) -- it means that if file will be 1 byte long it will occupy 4096 bytes, if it will be 4097 bytes long -- it will occupy 8192 bytes and so on. This is also means that you cannot create infinite number of empty files on the disk.
For real example: very long time ago i was testing a diskette (1.44mb formated with FAT16 file system. The size of cluster was 1 or 2 Kb -- don't remember exactly ). Any way -- you may try to create as much as possible empty files (just in the root of the diskette) -- you will see that it will be less than 200 (two hundred(!)) ......... i am not sure in exact values, but i hope you got me .
simple, using a FILE* pointer, using fseek to SEEK_END and getting the size with ftells, and theeeeen, the number in bytes, pas them to bits xD
this only works with files that aren't on a zip ...
Au Revoir !
this only works with files that aren't on a zip ...
Au Revoir !
My Gramathicalz horrorz are precalkulated, zo Zhut Up !
_______
Bah, actually my english is poor, but...
forget it xDDDD
_______
Bah, actually my english is poor, but...
forget it xDDDD
A byte can have a total value of 255 unsigned and 128 signed is that correct? including the 0. Where a Signed Value is either a - or + and Unsigned is +-.
Its based on the 2 to the power system so with 8 positions reading from right to left the values would be.
The use of binary can also be seen in color depths such as 16, 32 bit.
All digital processors are based of the stream of 0 or 1. 0 Being of and 1 being on. Or in boolean terms 0 being false and 1 being true.
[/code]
Its based on the 2 to the power system so with 8 positions reading from right to left the values would be.
Code: Select all
128(2^7), 64(2^6), 32(2^5), 16(2^4), 8(2^3), 4(2^2), 2(2^1), 1(2^0),
All digital processors are based of the stream of 0 or 1. 0 Being of and 1 being on. Or in boolean terms 0 being false and 1 being true.
[/code]
Programming Blog: http://www.uberwolf.com
There are short and long ints, irrlicht types like f32, u16 s32 etc... are useful because they remove the doubt.
(how does a compiler decide if a generic "int" is a short or a long? I dont know)
(how does a compiler decide if a generic "int" is a short or a long? I dont know)
"Irrlicht is obese"
If you want modern rendering techniques learn how to make them or go to the engine next door =p
If you want modern rendering techniques learn how to make them or go to the engine next door =p
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
int is neither long nor short, it's simply an int. There is also the type short, as well as long (and as an extension also long long - note that according to gcc long long long is too long ). There are no defined bit sizes for any of these types, the longer types just have to be at least the size of the smaller one, so char <= short <= int <= long <= long long. On 32bit machines, int is usually 32bit wide. However, on 64bit machines they are also 32bit wide. But there are also some systems which have smaller ints.