I found that when I compiled for the Mac, integers could be made very large. When I used Int64 and built for windows, it seemed that I was reduced to the integer size for windows, with consequent out of bounds errors.
I wrote this function to display a double as an integer in text, overcoming this problem
Function displayDoubleAsInteger(numberToDisplay as Double) As String
Var myString As String = Floor(numberToDisplay).ToText // number.000000
Var myIntegerAsInteger=myString.indexof(0,".") // where is the "."
myString = myString.Left(myInteger) // everything before the "."