ohadbp
July 16th, 2001, 04:12 AM
hello,
i m creating a calculator in 16 bit. how can i detect an overflow in run time?
ohad
i m creating a calculator in 16 bit. how can i detect an overflow in run time?
ohad
|
Click to See Complete Forum and Search --> : how to detect an overflow? ohadbp July 16th, 2001, 04:12 AM hello, i m creating a calculator in 16 bit. how can i detect an overflow in run time? ohad cksiow July 16th, 2001, 04:28 AM one way is to use larger data type to store the result and check for overflow. for instance, dim i as integer dim j as integer dim l as long l = i + j if l > 32767 then 'overflow end second way, use On Error Goto .... [vbcode] On Error Goto ErrorTrap dim i as integer dim j as integer dim k as integer k = i + j exit function ErrorTrap: 'if k overflow, this part of code will be executed ... HTH cksiow http://vblib.virtualave.net - share our codes codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |