Repost: Negative File Size

December 22, 2015 · Posted in Fun Things 

This is a repost of content from this blog before I decided to take down the existing content and start from scratch.

A couple of years ago, I was having trouble with a hard drive that did not want to function the way it was supposed to. Some data was lost, and some of it I was able to recover using file recover tools.

However, the files it recovered had some curious issues. Aside from being corrupted, some files seemingly gained the capability to store millions of terabytes of information inside them:

File size: 4.44659e-323 bytes

This is also a good example of why I think strongly defining data types is important: it would prevent strange appearances like this (along with all the potential problems that such a file might cause because no other code expects to ever see such a thing). If the developers at Microsoft had chosen to use an unsigned integer to handle file sizes (rather than blindly grabbing an int) — after all, a file can never be less than zero bytes in size — things like this could simply not happen.


Leave a Reply

A Soul Waking