multiplication R without float [closed]

孤人 提交于 2019-12-11 20:45:25

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/30923341/multiplication-r-without-float

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!