防止R舍入 [英] Preventing R From Rounding

查看:93
本文介绍了防止R舍入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止R舍入?

例如

> a<-893893084082902
> a
[1] 8.93893e+14

我在那里丢失了很多信息.我已经尝试过signif(),但它似乎并没有满足我的要求.

I am losing a lot of information there. I have tried signif() and it doesn't seem to do what I want.

提前谢谢!

(这是由于我的一个学生试图确定以一秒数计算一百万像素需要多长时间)

(This came up as a result of a student of mine trying to determine how long it would take to count to a quadrillion at a number per second)

推荐答案

这不是四舍五入.这只是打印大号(或小号)的默认格式.

It's not rounding; it's just the default format for printing large (or small) numbers.

a <- 893893084082902
> sprintf("%f",a)
[1] "893893084082902.000000"

有关全局解决方案,请参见?options的数字"部分.

See the "digits" section of ?options for a global solution.

这篇关于防止R舍入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆