Consulting

Results 1 to 2 of 2

Thread: Very large number: Mod operator

  1. #1
    VBAX Regular
    Joined
    Jun 2007
    Location
    Moscow
    Posts
    12
    Location

    Very large number: Mod operator

    Hello everyone, here's a little sub that causes overflow:

    [vba]
    Sub zzzzz()
    Dim a As Double, b As Double, c As Double
    a = 51
    b = 19
    c = 52
    Debug.Print (b ^ c) Mod a
    End Sub
    [/vba]

    By the way, if I do not use Mod operator, it gives the result of b^c as 3.12742749190775E+66. So the problem is with the "Mod" one.

    Does anyone know the solution? Thank you!! ^_^
    Sincerly Yours,
    千歳みどり, FRM

    Member of:
    www.riskofficer.ru, dom.bankir.ru, www.animeforum.ru

  2. #2
    This is because beyond a certain value (2^53), double = double + 1
    i.e. it loses resolution so your MOD question becomes irrelevant.
    2+2=9 ... (My Arithmetic Is Mental)

Posting Permissions

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