472,331 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

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 2025
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...
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...
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"...
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....
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...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...

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.