QBasic / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

Value range for K, K%, K&, K! AND K#

December 19 2001 at 2:31 PM
  (no login)

 

FAQ023 = What is the maximum size of a number?

K% INTEGER
   16-bit signed integer, Max = (2^15)-1 = 32,767

K& LONG
   32-bit signed integer, Max = (2^31)-1 = 2,147,483,647

K! SINGLE
   single-precision 32-bit floating-point
   Seven place accuracy, Max = 3.402823E+38

K# DOUBLE
   double-precision 64-bit floating-point
   Sixteen place accuracy, Max = 1.797693134862315D+308

Note: "K" is treated the same as "K!", in other words, the default selection is SINGLE. Of course if the user enters, for example
   DIM K AS INTEGER
then "K" will be treated as "K%"

What happens when you reach end-of-range:

  E%=32766
  E%=E%+1: 'This is OK
  E%=E%+1: 'This causes OVERFLOW error

  K=3.402822E+38: 'Note that "K" is the same as "K!"
  K=K+0.000001E+38: 'This is OK
  K=K+0.000001E+38: 'This causes OVERFLOW error

But look at this:
  K!=3.402822E+38
  K!=K!+0.000001E+38: 'This is OK as before
  K!=K!+10000000000000: 'This does nothing

This is because the number 10000000000000 is insignificantly small compared to 1E+38
Anything less than 0.000001E+38 will do nothing.
But 0.000001E+38 will cause an overflow.

(0.000001E+38 is usually written as 1E32)


    
This message has been edited by iorr5t on Jul 20, 2004 5:21 PM
This message has been edited by iorr5t on Mar 30, 2004 9:33 AM
This message has been edited by iorr5t on Jan 19, 2002 8:58 PM
This message has been edited by iorr5t on Dec 28, 2001 7:27 PM


 
 Respond to this message   
Responses

  • DEFs... - lkt153 on Jan 19, 2002
  •  
 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement