fpPlugin BigInteger and Mod

Hi,

I’m trying to generate iban from bban using Bob Delaney’s fpPlugin.
http://delaneyrm.com/fpPlugin.html

I get correct remainder of Mod if remaider is small, but bigger remaiders are negative values…

    dim ib as BigInteger
    dim jj as Integer
    ib = new BigInteger("12345678901234567894")
    jj = fpEquateINT32_BI( ib mod 11 )

For this jj is 5
But if I give “12345678901234567895” this jj is -5 (guess it should be 6)
and for “12345678901234567896” jj is -4 (guess it should be 7)

Am I doing something wrong or is this BigInteger not working with Mod?

Thanks

Jukka

Maybe Operator_Modulo is not implemented in BigInteger and some Operator_Convert is happening on (ib Mod 11).

bubblegum fix :slight_smile:

    dim ib as BigInteger
    dim jj as Integer
    dim mod_op As Integer = 11
    ib = new BigInteger("12345678901234567895")
    jj = fpEquateINT32_BI( ib mod mod_op )
    if jj < 0 then
      jj = Floor(mod_op/2) + (Ceil(mod_op/2)+jj)
    end if