[R] number precision

Duncan Murdoch murdoch at stats.uwo.ca
Sun Aug 19 00:29:19 CEST 2007

pieterprovoost at gmail.com wrote:
> Hi,
> I'm trying to find a way to determine how many digits a number has. I tried using nchar(paste(number)), but unfortunately paste will reduce 8.00 to "8".

I think your problem is that "the number of digits a number has" is not 
a property of the number (since the numbers 8.00 and 8 are the same 
number).  You need to keep track of the digits in some other way.  One 
possibility is to store two numbers:  the lowest possible value and the 
highest possible value.  Then 8.00 would be stored as (7.995,  8.005).  
It's then possible (but not easy) to propagate these ranges through 

Duncan Murdoch
> Any thoughts?
> Pieter
> --
> This message was sent on behalf of pieterprovoost at gmail.com at openSubscriber.com
> http://www.opensubscriber.com/messages/r-help@stat.math.ethz.ch/topic.html
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> 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.

More information about the R-help mailing list