473,473 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Why does ?2944*24 in the immediate window give me an overflow error?

MLH
?2944*24
gives me an overflow error, entered in the
immediate window. Anybody else?
Nov 13 '05 #1
7 2132
MLH
2944*24
gives me an overflow error, entered in the
immediate window. Anybody else?

Important to note is that the following calc's
fine - no error at all...

?2^64
1.844674E+19

Now where's the overflow error?
Nov 13 '05 #2
MLH
2944*24
gives me an overflow error, entered in the
immediate window. Anybody else?

Important to note is that the following calc's
fine - no error at all...

?2^64
1.844674E+19

Now where's the overflow error?

And furthermore...
?log(2944)+log(24)
11.16558
?exp(11.16558)
70656.119394842

Hmmm??? 70656 sounds about right to me.
Where's the overflow at now? How can the
immediate window not know 2944*24 = 70656
and yet know that exp(log(2944)+log(24)) = 70656?

It sure beats me!
Nov 13 '05 #3
"MLH" <CR**@NorthState.net> wrote in message
news:74********************************@4ax.com...
2944*24
gives me an overflow error, entered in the
immediate window. Anybody else?

Important to note is that the following calc's
fine - no error at all...

?2^64
1.844674E+19

Now where's the overflow error?

And furthermore...
?log(2944)+log(24)
11.16558
?exp(11.16558)
70656.119394842

Hmmm??? 70656 sounds about right to me.
Where's the overflow at now? How can the
immediate window not know 2944*24 = 70656
and yet know that exp(log(2944)+log(24)) = 70656?

It sure beats me!


It looks as though it is trying to fit the product into an integer (and
can't). Not too smart of Access is it. If you force either multiplier to
something other than integer first, it doesn't make that mistake.

?clng(2944) * 24
70656

?2944 * clng(24)
70656

IMHO (OK, not so humble), 2 byte integers on 32 bit systems make no sense.
Microsoft should have dropped 2 byte integers when they made the switch from
16 to 32 bit systems.

--
Randy Harris
(tech at promail dot com)
Nov 13 '05 #4
MLH wrote:
?2944*24
gives me an overflow error, entered in the
immediate window. Anybody else?


VBA is an archaic, inefficient language which sometimes treats literals
inefficiently.
In this case it looks at 2944 and say ... "integer" so
I should try to put 2944 into an integer.
It can't so it reports an overflow.

Dim l As Long
l = 2944
Debug.Print l * 24

This works fine because VBA recognizes l as a long.

It may be helpful to declare all variables and forget literals. I never
use the immediate window (except for debug.print) and am astounded by
the many posts which recommend it.

BTW, this accounts for the nonsense that True=-1.
When we make all the bits in an integer zero we get zero. This is false.
(All the flags are down)
When we do NOT to all those bits we change them all to 1's.
(All the flags are up)

And of course all ones is -1 (twos complement).
So, first VBA decides to treat True as an integer. Because it doesn't
have an unsigned integer it uses a signed integer. Arggggggggggggh.

255 (byte) is, in my opinion a much better numerical equivalent for
true. As a byte is not signed, we don't have the -1 absurdity.

Dim b As Byte
b = True
Debug.Print b '255
--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #5
MLH wrote:
?2944*24
gives me an overflow error, entered in the
immediate window. Anybody else?


what they said....

+ a tip for immediate window use, use the old fashioned type casting
suffixes, e.g.
?2944&*24
70656
?3.11-3.1
9.99999999999979E-03
?3.11@-3.1@
0.01

A bit quicker to type in than Clng, Cdbl, etc.

The characters are:
%=Integer
!=Single
&=Long
#=Double
@=Currency

--
[Oo=w=oO]

Nov 13 '05 #6
The default data type in VBA is Integer, so any result larger than 32767
overflows.

Convert one of the numbers to a Long, e.g.:
? CLng(2944) * 24
or you could use the type declaration character:
? 2944& * 24

Other typecasting functions: CDbl(), CCur(), CVDate(),...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthState.net> wrote in message
news:ff********************************@4ax.com...
?2944*24
gives me an overflow error, entered in the
immediate window. Anybody else?

Nov 13 '05 #7
MLH
Thanks All.
Excellent answers.
I think I've got a handle on it now.
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: BlackHawke | last post by:
Our program, game program Andromeda Online (www.andromedaonline.net) uses two programs- one to play the game, another to patch the game as updates come out. Players actually launch the updater...
15
by: Andrew Fedoniouk | last post by:
I have a simple test document which produce the following in Mozilla and Opera: http://terrainformatica.com/w3/p2/problem1.png Internet Explorer behaves as per recommendation (I guess) Did I...
1
by: mavrick101 | last post by:
I have a form that I want to submit to a different page and in a new window. I have done this using an HTML button and putting a target="_blank" attribute in the FORM tag. This does give me the...
5
by: Earth | last post by:
Hi all, I am new in javascript. And I would like to find out whether window.open use GET or POST. I have tried to find the FAQ but no finding. Please enlighten me or direct me to any FAQ. ...
1
by: John Ramsden | last post by:
I have ported a PHP MySQL app to PostgreSQL, and a pg_send_query() call is returning error code 2 (PGSQL_TUPLES_OK). Unfortunately the PHP manual lists the error codes but doesn't indicate what...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
15
by: Matt | last post by:
Is there a way to display the file selection window for a file input field via JavaScript? My goal is to emulate the behavior seen in Yahoo! Mail BETA. When adding an attachment, it displays a...
1
by: Weyus | last post by:
All, I have a tricky set of AJAX functionality that involves a popup window and in order to keep the synchronization issues straight, I need to be sure that I understand something about the...
1
by: Sanctus | last post by:
Why does Error log show database restarting everytime a transaction log backup runs? It also runs a checkdb as well. The log backups are scheduled through a maintenance plan. Is this normal?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.