On 09/07/2010 10:27 AM, Trafim Vanishek wrote:
Thanks everybody for referring me to FAQ 7.31 but I don't see how to solve
it.
I am giving a concrete number and I need to get 58 not 57. Seems, there is
no way?
You aren't giving a "concrete number". You're giving a string of three characters, which R interprets as a number that's a little bit less than 0.58, because there is no way to represent the number 0.58 in the floating point format that R uses. So it is calculating the right answer.

If you want to work with exact 2 decimal place values, you should not use floating point storage. One alternative is to work with integers equal to 100 times the value you want, and then divide by 100 at the very end of the operation for printing.

Duncan Murdoch
On Fri, Jul 9, 2010 at 4:05 PM, David Winsemius <dwinsem...@comcast.net>wrote:

>
> On Jul 9, 2010, at 9:46 AM, Trafim Vanishek wrote:
>
>  Dear all,
>>
>> might seem and easy question but I cannot figure it out.
>>
>> floor(100*(.58))
>> [1] 57
>>
>> where is the trick here?
>>
>
> FAQ 7.31
>
>
> And how can I end up with the right answer?
>>
>
> Define right, please. (There have been several questions in the last week
> for which FAQ 7.31 was the answer and some of the responses had useful
> links.)
>
> --
> David Winsemius, MD
> West Hartford, CT
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.


______________________________________________
R-help@r-project.org 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.

Reply via email to