Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
oVERFLOW
#6
Code:
[code]
In thie program below, I get no OVERFLOW error on lines 3 and 4, but I do on line 5.  I would have thought that the line "a = 1000", since 1000 is automatically assigned data type SINGLE, would also assigne SINGLE status to a.  In that case, lines 3 and 4 would have given me the OVERFLOW error; but, since I didn't get that error, it seemed to me that "a" remains as defined, a LONG data typee.  That would explain why neither lines 3 nor 4 give an OVERFLOW.  Then, I added the line, "PRINT LEN(a)" just before line 2, and also just after line 2; and got the length of "a" as 4 both times, confirming that it remains a LONG data type, even though line 2 might have converted it to a SINGLE data type, I would have thought, in the sake of memory economy.  Well, even Microsoft isn;t logical all the time, I guess.   Inow  see the heavy use of the symbols %, &, !, and # as a cop-out to not have to remember all the rules about what happens to variable data types throughout mathematical operations!  Do you agree with me?   

[code]
1 DEFLNG A-Z
2 a = 1000
3 b = a * a
4 b = 1000 * a
5 b = 1000 * 1000
[/code]

Edited some time later, by Ralph:
But, wait a while!  I just ran the above program, after removing line 1, and, I still get the length of a as 4!  And the same OVERFLOW for line 5.  Why?

The following program runs fine, but, if I reduce the first value in line 7 from 1,000,000,000 to 100,000,000, I get an OVERFLOW in this line.  It would seem that one billion is either a  LONG ineger or a DOUBLE precision variable, even though itis not so indicated, and that one hundred million is acting as either a "SHORT" integer or as a SINGLE precision variable. 
Code:
1 CLS
2 PRINT LEN(a)
3 a = 100000
4 PRINT LEN(a)
5 b = a * a
6 b = 100000 * a
7 b = 1 000 000 000 * 1000000

So, is my above analysis correct?  If not, what is the explanation?  And, why is it that one hundred billion is not shown with its LONG or DOUBLE precision symbol?  Explanations, anyone?  [/code]
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply


Messages In This Thread
oVERFLOW - by Ralph - 10-08-2008, 03:24 AM
Re: oVERFLOW - by Ralph - 10-13-2008, 10:51 PM
Re: oVERFLOW - by Clippy - 10-14-2008, 03:22 AM
Re: oVERFLOW - by Moneo - 10-14-2008, 05:15 AM
Re: oVERFLOW - by Ralph - 10-14-2008, 10:13 AM
Re: oVERFLOW - by Ralph - 10-14-2008, 11:17 PM
Re: oVERFLOW - by Moneo - 10-15-2008, 06:04 AM
Re: oVERFLOW - by Ralph - 10-15-2008, 08:02 AM
Re: oVERFLOW - by Clippy - 10-15-2008, 10:15 PM
Re: oVERFLOW - by Ralph - 10-16-2008, 02:30 AM
Re: oVERFLOW - by Moneo - 10-16-2008, 04:34 AM
Re: oVERFLOW - by Ralph - 10-16-2008, 05:16 AM
Re: oVERFLOW - by Moneo - 10-16-2008, 06:06 AM
Re: oVERFLOW - by Ralph - 10-16-2008, 08:54 AM
Re: oVERFLOW - by Clippy - 10-16-2008, 10:25 AM
Re: oVERFLOW - by Moneo - 10-16-2008, 11:29 PM
So you are just stubborn then! - by Clippy - 10-17-2008, 03:58 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)