QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

You can stretch it some by using #

July 5 2008 at 9:42 AM
  (Login The-Universe)
Admin


Response to Numbers bigger than 1,000,000,000

 

CLS
INPUT x#
PRINT x# + x#
END

---------------------

Also check it with numbers like:

x# = 100000000002345#

or

x# = VAL("100000000002345")

Integers are limited to -32768 to 32767 but double precision numbers go much further. You can also use DIM x as DOUBLE at the top of your program as in:

DIM x as DOUBLE
INPUT x
PRINT x + x
END

Double precision will give you up to 15-digits to use for the sum of your numbers. Beyond that, you would need to convert with strings and a function to add together. I know you stated integers, which means you could use long (&) but double allows for larger integers than long does, even though it 'doubles' for decimal numbers.

Personally, I always like to convert to strings for most applications to avoid other problems but if this gets you by for what you need, great. I would like to know what type of project you are working on and if you need some help in the future, just post the code you have so far and ask for help where you are stuck?

Pete



    
This message has been edited by The-Universe on Jul 5, 2008 9:55 AM


 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement