Weird values from an int function

Something else is going on with the code you did not post.

It works fine for me.