乘法R无浮点数 [英] multiplication R without float

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

问题描述

有一种方法可以用系列中的浮点数乘以整数乘以两个整数。我需要写一个函数接受输入值,如

3.4556546e-8

1.3



0.134435

而不是100 * 0.134435它会做
100/1000000
然后乘以

$ 134435

该函数应该作为输出只是给1000000和134435 - 它只是需要因为我需要处理一些非常大的数字在大整数和mutipliying与anythign除了整数doent work

解决方案

显然你想做任意精确的算术。

  library(gmp)
x< - as.bigq(0.134435 )
100 * x
#Big Rational('bigq'):
#[1] 121088283181110525/9007199254740992


is there a way to do the multiplication with a float in a serie sof two multiplications with integers. I would need to write a function which accepts as input values such as

3.4556546e-8

1.3

0.134435

Instead of doing 100*0.134435 it would do 100/1000000 and then multiply with

134435

the function should as output just give 1000000 and 134435 - it is just needed because i need to work with some very large numbers in big integers and mutipliying with anythign except for intgers doent work

解决方案

Apparently you want to do arbitrary precision arithmetics. You don't need to reinvent the wheel.

library(gmp)
x <- as.bigq(0.134435)
100 * x
#Big Rational ('bigq') :
#  [1] 121088283181110525/9007199254740992

这篇关于乘法R无浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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