This MR fixes issue #2470 (closed). I wanted to add some tests which would check that we always do the right thing when dealing with larger integer types but due to the vagueness that we face in C this seems harder to do generically. Therefore, I decided not to add any tests. Once (if ever) we have a good solution for the C observations of issue #2506, we should add nice generic tests....