Unfortunately however, I have hit a further stumbling block. If the duchy has a population of over 4 million, then the population variable doesn't get applied properly to the provinces. If the duchy's population is something like 300,000 it works fine though. So it seems like I've hit a maximum limit to how large a variable can be?
Since variables use three decimals, then probably their maximum limit is 2,147,483.647 (they are probably just integers with the three last numbers appearing as decimals).
I suppose I could use thousands of people for the variable instead, though that isn't as appealing, visually.
Thanks for the help with this issue,
@Attila2131