On 02/02/2016 4:28 PM, Glenn Schultz wrote:
All,

I am modeling a FNMA credit risk transfer deal.  The size of the collateral 250 
billion.  Naturally, the cashflow is quite large the cash flow is calculated 
and stored in a S4 object which is then converted to an array and the result is 
character values - converting back to numeric I lose the decimal unless I set 
options(digits = 22).  Are there any other options available.  I have searched 
the internet and well as some R sites and it seems this maybe my only option.

Most R values are stored in double precision, which gives 15-16 digit accuracy. That should give you values accurate to 1 cent in 10^13 dollars, which covers your range.

Automatic conversion to characters shouldn't happen. If it does, something is going wrong in your computations. (It happens when you mix characters and numbers in the same vector. Don't do that.)

At the end when you want to print, you need to convert to character. You can use options(digits=) to set the default number of digits, or you can do the conversion explicitly, using format(), sprintf(), or a related function. It's up to you how many decimals you print.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to