有符号和无符号的int [英] Signed and unsigned int

查看:81
本文介绍了有符号和无符号的int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

签名的int最多可以包含2Gig,2 147 483 648。


自从火星探测器降落以来,我一直在存储

照片分为两个目录,Spirit和Opportunity。我在一个目录中有超过18 000个文件。
在没有意识到这一点的情况下,我上周越过了2 147 483 648边界。


如果您不尝试读取所有文件,则没有任何反应目录,

甚至最差,将它们复制到另一个驱动器。


由于神秘的磁盘错误,我试图保存我的工作。然而,当复制到副本时,副本到达图像时出现错误

并且无法读取它。


愚蠢的我,我试图再次复制文件。


就是这样:磁盘开始产生周期性的机械噪音,并且

它是GONE跟我在磁盘上的所有数据一样!!!!!!!!!!!!!!!!!!!!!

为什么?

当有符号整数增加到2147483648以上时,它变为负数。

这意味着系统将向

读头发出NONSENSE movemevent命令,立刻摧毁磁盘。


我很幸运。我在linux系统中对火星数据进行了完整备份。啊?

Microsoft。

我启动了运行ext2文件系统的linux机器。我发了订单给b
复制

文件,并在复制期间开始做其他事情。


当金额为数据传输到了大约2GB,我听到了

恐怖,

磁盘开始做同样的重复机械噪音和我的linux

系统

已经消失,我已经失去了几个月的工作而没有任何方法可以获得我的数据




有符号整数可以包含最多2147483648个字节。不是一个字节。


我已经开发了一个编译时间开关来检查

lcc-win32和

内的溢出几个星期前在这里发布了一条消息。没有人愿意回答。


SHIT !!!!!!!!!!!

C是一种不错的语言,可以用来写文件系统。但是它会更好

to

小心这些int好吗?


你不相信我吗?


试一试。制作几个目录,每个文件有100-200K

,直到

你得到2GB以上。


但备份你的车开始......


jacob

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.

SHIT !!!!!!!!!!!

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


推荐答案

文章< cf ********** @ news-reader4.wanadoo.fr>,

" jacob navia" < JA *** @ jacob.remcomp.fr>写道:
In article <cf**********@news-reader4.wanadoo.fr>,
"jacob navia" <ja***@jacob.remcomp.fr> wrote:
试试吧。制作几个目录,每个目录包含数千个100-200K的文件,直到
你得到2GB以上。

但是先备份你的驱动器......
Try it. Make several directories with several thousand files of 100-200K
each, until
you get more than 2GB.

But backup your drive first...




数码摄像机每个seoncd正好记录360万字节。

即每分钟2.16亿字节,或每小时12,960,000,000字节。我的b $ b目录在我的硬盘上有大约13千兆字节的内容,我的

邻居在一个目录中大约有30千兆字节 - 只需要2个半小时

的数字视频。


两台机器都是使用HFS +文件系统的Mac机,但我认为

有适用于Windows的视频编辑软件和Linux,我相信它

必须能够处理类似数量的数据。



A digital video camera records exactly 3.6 million bytes per seoncd.
That is 216 million bytes per minute, or 12,960,000,000 byte per hour. I
have directories on my harddisk with about 13 Gigabyte of contents, my
neighbour has about 30 Gigabyte in a single directory - just 2 1/2 hours
of digital video.

Both machines are Macs using the HFS+ filesystem, but I would think that
there is video editing software for Windows and Linux, and I am sure it
must be able to handle similar amounts of data.


jacob navia在10/08/04写道:
jacob navia wrote on 10/08/04 :
一个有符号的int最多可以包含2Gig,2 147 483 648。
A signed int can contain up to 2Gig, 2 147 483 648, to be exact.




当然你的意思是


签名长可以包含至少2Gig,2 147 483 648,确切地说是







在我的机器上,签名的int最多可包含2Gig,2 147 483 648,确切地说是



-

Emmanuel

C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html


C是一个尖锐的工具



Of course you meant

"A signed long can contain at least to 2Gig, 2 147 483 648, to be
exact."

or

"On my machine, a signed int can contain up to 2Gig, 2 147 483 648, to
be exact."

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"


jacob navia写道:
jacob navia wrote:
一个签名的int can最多包含2Gig,2 147 483 648。


" Exact"如果你忽略了一个一个错误...

自从火星探测器降落以来,我一直将
照片存储在两个目录中,即Spirit和Opportunity。我在一个目录中有超过18000个文件。在没有意识到的情况下,我上周越过了2 147 483 648边界。
[...和两个不同的O / Ses破坏了数据]。

C是一种编写文件系统的好语言。但是,对于那些小心的人来说,这样做会更好。
好吗?


雅各布,虽然我真的很抱歉你的数据丢失,但我认为你可能会找错了罪魁祸首。现在任何文件系统似乎不太可能内置31位限制;磁盘

已经很长时间了2GB以上。事实上,长时间以来,磁盘已经大于4GB;你可能需要长时间查看
并且很难找到今天很小的驱动器。如果使用这些较大驱动器的文件

系统受到31位或

甚至32位字节数的限制,那么除了你以外还有很多人

注意到了......

你不相信我吗?

试一试。制作几个目录,每个目录有几千个文件,每个100-200K,直到
你得到2GB以上。
A signed int can contain up to 2Gig, 2 147 483 648, to be exact.
"Exact" if you ignore the off-by-one error ...
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.
[... and two different O/Ses trashed the data].

C is a nice language in which to write file systems. But IT WOULD BE BETTER
TO
BE CAREFUL WITH THOSE "int" s OK?
Jacob, while I''m genuinely sorry for your data loss I think
you may have fingered the wrong culprit. It seems unlikely that
any file system nowadays would have a 31-bit limit built in; disks
have been larger than 2GB for a long time now. In fact, disks have
been larger than 4GB for a long time; you''d probably need to look
long and hard to find a drive that small today. And if the file
systems using these larger drives had been limited by 31-bit or
even 32-bit byte counts, plenty of people other than you would
have noticed ...
You do not believe me?

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




嗯,我是使用50-100MB的文件代替,但我希望你能接受(稍微编辑过)的证据无论如何:


文件系统kbytes使用的有效容量已安装on

/ dev / dsk / c14t40d0s6 356770888 37071528 316131656 11%(版主)

/ dev / dsk / c14t40d1s6 356770888 37140512 316062672 11%

/ dev / dsk / c13t40d0s6 356770888 37150672 316052512 11%

/ dev / dsk / c16t40d0s6 356770888 37206864 315996320 11%

/ dev / dsk / c13t40d1s6 356770888 37356592 315846592 11%

/ dev / dsk / c15t40d0s6 356770888 37412760 315790424 11%

/ dev / dsk / c16t40d1s6 356770888 53911776 299291408 16%

/ dev / dsk / c15t40d1s6 356770888 54248872 298954312 16%


我敢打赌31位限制(你悲伤的故事中的数字

太巧合而​​忽略了)与文件

系统无关。也许,它可能与实用程序有关。

你用来批量复制所有数据。


我的哀悼。


-
Er ********* @ sun。 com



Well, I''m using files of 50-100MB instead, but I hope you''ll
accept the (slightly edited) evidence anyhow:

Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c14t40d0s6 356770888 37071528 316131656 11% (withheld)
/dev/dsk/c14t40d1s6 356770888 37140512 316062672 11%
/dev/dsk/c13t40d0s6 356770888 37150672 316052512 11%
/dev/dsk/c16t40d0s6 356770888 37206864 315996320 11%
/dev/dsk/c13t40d1s6 356770888 37356592 315846592 11%
/dev/dsk/c15t40d0s6 356770888 37412760 315790424 11%
/dev/dsk/c16t40d1s6 356770888 53911776 299291408 16%
/dev/dsk/c15t40d1s6 356770888 54248872 298954312 16%

I''d bet that the 31-bit limit (the number in your sad tale
is too coincidental to ignore) has nothing to do with the file
system. It may, perhaps, have something to do with the utility
you were using to mass-copy all that data.

My condolences.

--
Er*********@sun.com


这篇关于有符号和无符号的int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆