Fixed warning: converting to int from double by making typecast explicit.