View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Abe Thomas[_2_] Abe Thomas[_2_] is offline
external usenet poster
 
Posts: 2
Default Overflow error occurs when multiplying integer constants in ex

Yes that works, but that just confirms the problem.
It appears to me that the temporary holding value in excel this case is just
another integer. Should probably be a at least a long int ?
Note that it works when larger numbers are multiplied.

I think its a bug ... with an easy workaround.

"Mike H" wrote:

Anyone out that aware of this problem ?


if you check help for overflow error 6 then you'll see why, try

i1 = 2 * CLng(32767)

Mike

"Abe Thomas" wrote:

An overflow error occurs when 2 integer constants (< 32768) are multiplied
that results in a value that is higher than what an integer can hold - see
code below.
This happens all the excel versions I tested.

Anyone out that aware of this problem ?

Sub Mult_Of_2_IntegerConstants_that_result_in_a_LongIn t()
Dim i1 As Long

i1 = 1 * 32767 ' This works since the result is less than 32768

i1 = 2 * 32767 ' This results in an OVERFLOW (the answer is = 32768)

i1 = 2 * 32768 ' This works since one of the operands is = 32768

End Sub