Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > signed and unsigned int

Reply
Thread Tools

signed and unsigned int

 
 
jacob navia
Guest
Posts: n/a
 
      08-10-2004
A signed int can contain up to 2Gig, 2 147 483 648, to be exact.

Since The Mars rovers landed, I have been storing the
photographs in two directories, Spirit and Opportunity. I had
more than 18 000 files in a single directory. Without being
aware of it, I crossed the 2 147 483 648 border last week.

Nothing happens, if you do not attempt to read all files in the directory,
or even worst, copy them to another drive.

Worried by mysterious disk errors, I tried to save my work. When making
the copy however, there was an error when the copy arrived at an image
and could not read it.

Foolish me, I tried to copy the file again.

That was it: the disk started to make a periodic mechanical noise, and
it was GONE ALONG WITH ALL MY DATA IN THE DISK!!!!!!!!!!!!!!!!!!!!!

Why?

When a signed integer is increased beyond 2147483648, it becomes NEGATIVE.
This means that the system will issue a NONSENSE movemevent order to the
read heads, destroying the disk instantly.

I was lucky. I had a full backup of the mars data in my linux system. Ahh
Microsoft.
I fired up the linux machine running ext2 file system. I issued the order to
copy
the files, and started doing other things during the copy.

When the amount of data transmitted arrived at approx 2GB, I heared with
horror that
the disk started doing the SAME repeating mechanical noise and my linux
system
WAS GONE, I HAVE LOST several months of work without any means of getting
my data back.

Signed integer can contain up to 2147483648 bytes. Not a single byte more.

I have developed a compile time switch to check for overflows within
lcc-win32 and
posted here a message, several weeks ago. Nobody cared to answer.

**** !!!!!!!!!!!

C is a nice language in which to write file systems. But IT WOULD BE BETTER
TO
BE CAREFUL WITH THOSE "int" s OK?

You do not believe me?

Try it. Make several directories with several thousand files of 100-200K
each, until
you get more than 2GB.

But backup your drive first...

jacob
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      08-11-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (jacob navia) writes:
> A signed int can contain up to 2Gig, 2 147 483 648, to be exact.

[snip]

Did you mean to post this twice?

Followups redirected to /dev/null; please reply to the original post,
so we don't get two distinct threads.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
 
Neil Kurzman
Guest
Posts: n/a
 
      08-12-2004


jacob navia wrote:

> A signed int can contain up to 2Gig, 2 147 483 648, to be exact.
>
> Since The Mars rovers landed, I have been storing the
> photographs in two directories, Spirit and Opportunity. I had
> more than 18 000 files in a single directory. Without being
> aware of it, I crossed the 2 147 483 648 border last week.
>
> Nothing happens, if you do not attempt to read all files in the directory,
> or even worst, copy them to another drive.
>
> Worried by mysterious disk errors, I tried to save my work. When making
> the copy however, there was an error when the copy arrived at an image
> and could not read it.
>
> Foolish me, I tried to copy the file again.
>
> That was it: the disk started to make a periodic mechanical noise, and
> it was GONE ALONG WITH ALL MY DATA IN THE DISK!!!!!!!!!!!!!!!!!!!!!
>
> Why?
>
> When a signed integer is increased beyond 2147483648, it becomes NEGATIVE.
> This means that the system will issue a NONSENSE movemevent order to the
> read heads, destroying the disk instantly.
>
> I was lucky. I had a full backup of the mars data in my linux system. Ahh
> Microsoft.
> I fired up the linux machine running ext2 file system. I issued the order to
> copy
> the files, and started doing other things during the copy.
>
> When the amount of data transmitted arrived at approx 2GB, I heared with
> horror that
> the disk started doing the SAME repeating mechanical noise and my linux
> system
> WAS GONE, I HAVE LOST several months of work without any means of getting
> my data back.
>
> Signed integer can contain up to 2147483648 bytes. Not a single byte more.
>
> I have developed a compile time switch to check for overflows within
> lcc-win32 and
> posted here a message, several weeks ago. Nobody cared to answer.
>
> **** !!!!!!!!!!!
>
> C is a nice language in which to write file systems. But IT WOULD BE BETTER
> TO
> BE CAREFUL WITH THOSE "int" s OK?
>
> You do not believe me?
>
> Try it. Make several directories with several thousand files of 100-200K
> each, until
> you get more than 2GB.
>
> But backup your drive first...
>
> jacob


1. This is OT
2. an "int" can be 16, 32 or 64 bits. It is the compiler / OS / CPU decision.

3. choice of signed unsigned is the programmers choice.
4. fatal overflows are the programmers fault.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(int) -> (unsigned) -> (int) or (unsigned) -> (int) -> (unsigned):I'll loose something? pozz C Programming 12 03-20-2011 11:32 PM
Convert 32 bit unsigned int to 16 bit signed int. Fore C++ 29 09-21-2008 05:55 AM
comparison between signed int and unsigned int Alex C Programming 3 04-26-2006 05:20 AM
unsigned int with signed long int (same width) - how is conversion done? G Fernandes C Programming 2 02-16-2005 10:55 AM
convert signed int to unsigned int Siemel Naran C++ 3 11-29-2004 08:22 AM



Advertisments