Results 1 to 2 of 2

Thread: *SOLVED* Overflow when dividing

  1. #1

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Question *SOLVED* Overflow when dividing

    ok...
    im making a paint program, and when the user is going to draw a straight line, he has to do as in mspaint: hold down shift....
    the problem is when the program is going to calculate the M value and the K value of the line...

    here's a bit of the code:

    If Shift = 1 Then
    KValue = (Y - StartY) / (X - StartX)
    MValue = Y - X * KValue
    End If

    but it cant do the division!! it gives me the overflow error!
    why?
    Last edited by cyborg; Apr 21st, 2002 at 10:20 PM.
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  2. #2
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    make sure that

    make sure that k and m are not defined as bytes (which can't be more then 255 or less then 0 (I really really hope u knew that)) or that ur not dividing by 0, make sure x - xstart doesnt = 0 so

    if not x - xstart = 0 then
    KValue = (Y - StartY) / (X - StartX)
    else
    kvalue = 0 'or whatever will work right...
    end if
    MValue = Y - X * KValue
    Don't pay attention to this signature, it's contradictory.

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