Results 1 to 7 of 7

Thread: Mod Overflow?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    13

    Question Mod Overflow?

    Why do I get an overflow error while doing 055755241763 Mod 94?

    It is being output to a variable that is of type double...

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Probably because 055755241763 is simply too big for the Mod.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    13
    Then whats the max number for mod? Is there any war around this?

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    After a bit of experimenting, the max number is 999999999 (9 chars long). Anything above that causes the overflow. I can't think of anyway way round it. Even if you took only a quarter of that number it would still be 11 chars long.

  5. #5
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Create your own mod operator by seeing if:

    number/interval = int(number/interval) then 0 else get remainder

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    13
    Function Modular(Num1, Num2)
    Divided = Num1 / Num2
    If Divided = Int(Divided) Then
    Modular = 0
    Else
    FractionPart = Divided - Int(Divided)
    Modular = FractionPart * Num2
    End If
    End Function
    Last edited by StuMan1337; May 27th, 2001 at 07:16 PM.

  7. #7
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Code:
    Function NuMod(ByVal x As Double, y As Double) As Double
     'Nucleus
     x = CInt(x): y = CInt(y) 'round floating point numbers To integers
     If x / y = CInt(x / y) Then NuMod = 0 Else NuMod = x - Int(x / y) * y
    End Function
    Last edited by Nucleus; May 27th, 2001 at 07:49 PM.

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