How to display a double as an out of bounds integer string when in Windows

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 “.”
return myString
End Function

Why don’t you use http://documentation.xojo.com/api/text/format.html ?

Integer sizes are the same on Mac and Windows, and integer overflows won’t trigger an OutOfBoundsException. I suspect something else was the problem.

[quote=477241:@Philip Cumpston]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 “.”
return myString
End Function[/quote]
You will however get an out of bounds exception if numberToDisplay starts out with a whole number without a decimal. IndexOf would return -1 and Left(-1) triggers the exception.

Thanks for the input everyone. It was a weird error. I thought that integer out of bounds shouldn’t occur, but whenever I passed a double to an integer for display purposes, it would give a negative number like an out of bounds error whenever I exceeded 32000 or so.
I overlooked the Format function - thanks Emile. I am still tracking down the error, but I suspect that using Floor and then converting it to an integer does something weird in Windows but not in OSX

What version of xojo and windows are you using?

Xojo 2019 release 3.1 - Mac Cataline, windows 10 under VMWare

[quote=477300:@Philip Cumpston]Thanks for the input everyone. It was a weird error. I thought that integer out of bounds shouldn’t occur, but whenever I passed a double to an integer for display purposes, it would give a negative number like an out of bounds error whenever I exceeded 32000 or so.
I overlooked the Format function - thanks Emile. I am still tracking down the error, but I suspect that using Floor and then converting it to an integer does something weird in Windows but not in OSX[/quote]
You wouldn’t happen to also be using this number for defining the width or height of a picture, would you?