added toDouble method to overcome R's integer overflow problem
*should be OK now (passes the seed 45189810