protection added in order to avoid an undefined behaviour when the casting to int is done on top of a double with a value greater than INT_MAX
Merge pull request #196 from deguio/protectionWhenCasting

protection added in order to avoid an undefined behaviour when the casting to int