Results 1 to 6 of 6

Thread: weird overflow...

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    2

    Question

    why for exemple is 139 multiplied by 256 issue an overflow while 143 multiplied by 65536 doesn't.

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    I think everyone stumbles across this sooner or later.
    it's because VB assumes 256 and 139 are integers and therefore can only be up to 32,767.

    if you force one to be a long it's OK

    eg. 139 * clng(256)

    Maybe VB is actually trying to optimise!



    Mark
    -------------------

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    2

    Cool overflow

    thank for the hint Mark.





  4. #4
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Re: overflow

    Keep you math in declared vars and constants so you know what types you're dealing with, numbers don't tell you enough

    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  5. #5
    Guest
    If you're dealing with really big numbers, you can declare it as Decimal or Currency

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hint and hint, here's the actiul hint:

    Declare your values!

    Code:
     ?256&*256&
    
     ?65536@*65536@
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width