Integer - Assigned and Display both is different

dim I as Integer

i = 14630795872

msgbox(i.ToText) -> 1745893984

Why is showing different number?

integer in a 32 bit build is a 32 bit value
14,630,795,872 exceeds the range a int32 can hold
http://developer.xojo.com/integer

Because the static value you are assigning is outside the range of an Int32 (what Integer defaults to on a 32-bit build). Try declaring i as an Int64 instead.

If you happen to have this appearing on a 32Bit system, it is because you are running onto a bit overflow. Maximum for a 32Bit integer is 2147483647. Use UInteger or better Int64 (or UInt64).

EDIT: Only third in the race :smiley:

why there is no exception raised

There are no integer overflow, underflow exceptions and never have been (and are unlikely to be)

From the notes on the Integer doc page:

ok thanks for info
is there any way complier can show warning will be helpfull

[quote=265659:@Jiten Shah]ok thanks for info
is there any way complier can show warning will be helpfull[/quote]

If you fear overflowing Integer, won’t you simply use Int64 instead ?

http://documentation.xojo.com/index.php/Integer_data_type

That is what I am using now

You would have to write an overflow check yourself, although with a Int64 you could wait a long time until it occurs. But if you want, you could write an extension method for integer that checks if a value that is being added is bigger than maxint – current value.