Typecasting to integer doesn't actually typecast