Use a matching integer type instead of casts, as a cleaner follow-up to r1872108. Suggested by: brane