alteryx Community

# Alteryx Designer Discussions

## Re: Modulo (mod) Function: Not just for Evens and Odds

7 - Meteor

Hi 🙂

in order to check IBANs, I want to calculate the modulo 97 of very large numbers. In my example the number is 700901001234567890131400. Two websites independently say, that the result of 700901001234567890131400 modulo 97 is 90 (e.g. https://www.entwicklertools.de/tools/mathematik-tools/modulo-rechner/). But when I calculate it with Alteryx the result is -79. The reason for this miscalculation seems to be, that the Formula-Tool can not handle numbers, that are as large as the first one. Does anyone have an idea how to work around that?

4 REPLIES 4
16 - Nebula

correction - you asked this question 3 months ago - and @Qiu made you a macro... as I said at the time -mod is an integer function and your number is larger than Int64. it will not work with mod on Alteryx... or excel.. there might be a python/r way.

17 - Castor

@apathetichell
Wow, I did not recall until you brought it up. Thanks a lot.

@FlorianH

I can anwser some queries from you after your review of the flow.

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/MOD-formula-gives-unexpected-result/td...

16 - Nebula

FYI here's the R way...

install.packages("VeryLargeIntegers", repos='http //cran.us.r-project.org')
library(VeryLargeIntegers)

VLIMOD <- data.frame(c("value"))
for (i in 1:nrow(dat)) {
x <- as.vli(as.character(dat\$VLI[i]))
VLIMOD[i] <- as.numeric(summod(x,0,dat\$Divisor[i])\$value)}

write.Alteryx(VLIMOD,1)

this assumes:

1) you don't have VeryLargeIntegers  already installed and you can install packages in your R Tool

2) you MUST name your columns VLI (for the big number) and Divisor for the number you are dividing by.

3) you'll have to transpose the output because everything is in one row.

7 - Meteor

Hi @Qiu

thanks a lot! Unfortunately I'm not at all familiar with macros in Alteryx. I will try to solve it with python now.

Thanks anyway.

Cheers

Florian

Labels