一般一个整形很小的时候定义var aa:integer就行了,现在我有一个30位的整数,怎么定义呢??? ( 积分: 54 )

  • 主题发起人 主题发起人 wanglong
  • 开始时间 开始时间
W

wanglong

Unregistered / Unconfirmed
GUEST, unregistred user!
一般一个整形很小的时候定义var aa:integer就行了,现在我有一个30位的整数,怎么定义呢??由于定义不了它,想给他加1都不行啊,哪位高手会给长为30位的整数加上1。
 
一般一个整形很小的时候定义var aa:integer就行了,现在我有一个30位的整数,怎么定义呢??由于定义不了它,想给他加1都不行啊,哪位高手会给长为30位的整数加上1。
 
把它分成高15位和低15位就可以算了
 
http://www.2ccc.com/article.asp?articleid=2071
大数字相乘的演示程序
看看这个???
 
var w:Int64;
 
Shortint -128..127 signed 8-bit
Smallint -32768..32767 signed 16-bit
Longint -2147483648..2147483647 signed 32-bit
Int64 -2^63..2^63-1 signed 64-bit
Byte 0..255 unsigned 8-bit
Word 0..65535 unsigned 16-bit
Longword 0..4294967295 unsigned 32-bit
 
这是delphi帮助文档里的介绍,好好看看就知道怎么办了!

An integer type represents a subset of the whole numbers. The generic integer types are Integer and Cardinal
use these whenever possible, since they result in the best performance for the underlying CPU and operating system. The table below gives their ranges and storage formats for the current 32-bit Delphi compiler.

Generic integer types for 32-bit implementations of Delphi
Type Range Format
Integer -2147483648..2147483647 signed 32-bit
Cardinal 0..4294967295 unsigned 32-bit
Fundamental integer types include Shortint, Smallint, Longint, Int64, Byte, Word, and Longword.

Fundamental integer types
Type Range Format
Shortint -128..127 signed 8-bit
Smallint -32768..32767 signed 16-bit
Longint -2147483648..2147483647 signed 32-bit
Int64 -2^63..2^63-1 signed 64-bit
Byte 0..255 unsigned 8-bit
Word 0..65535 unsigned 16-bit
Longword 0..4294967295 unsigned 32-bit
In general, arithmetic operations on integers return a value of type Integer--which, in its current implementation, is equivalent to the 32-bit Longint. Operations return a value of type Int64 only when performed on one or more Int64 operand. Hence the following code produces incorrect results.

var
I: Integer;
J: Int64;
...
I := High(Integer);
J := I + 1;

To get an Int64 return value in this situation, cast I as Int64:

...
J := Int64(I) + 1;

For more information, see Arithmetic operators.

Note

Some standard routines that take integer arguments truncate Int64 values to 32 bits. However, the High, Low, Succ, Pred, Inc, Dec,
IntToStr, and IntToHex routines fully support Int64 arguments. Also, the Round, Trunc, StrToInt64, and StrToInt64Def functions return Int64 values. A few routines cannot take Int64 values at all.

When you increment the last value or decrement the first value of an integer type, the result wraps around the beginning or end of the range. For example, the Shortint type has the range -128..127
hence, after execution of the code

var I: Shortint;
...
I := High(Shortint);
I := I + 1;

the value of I is -128. If compiler range-checking is enabled, however, this code generates a runtime error.
 
完全同意rainylgh。强烈呼吁楼主先好好看看delphi 的帮助,integer(在32位的操作系统里面)就是32位的!当然,它是有符号的,如果你想用无符号整数,可以用Longword类型。
 
高精度存吧
去找找高中pascal的书
 
初中时用Basic的字符串模拟了一把 可以实现任意长整数 +-*
/没有实现,效率问提没有想到好办法
 
int64,还有一个无符号的Int64,在windows单元里面自己找以下,其他的楼上说很清楚了
 
后退
顶部