Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
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
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Besides the impossibility of representing decimal numbers like 0.1 in a binary base, and, the inaccuracy by design of denormalized floats; is there any other source of inaccuracy when working with double floating-point numbers?
Just one strange example of numerical inaccuracy of floats is as follows:
If one converts 9999999.4999999999 to a float and back to a double, the result is given as 10000000, even though that value is obviously closer to 9999999, and even though 9999999.499999999 correctly rounds to 9999999.
I understand that this is a very specific example, but more detailed (and scientific reasoning!) can be found here:
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
For one of my projects I would like to create several random matrices, which have full rank. Does anybody know a quick way to do this in R or has an idea how to proceed?
You are overwhelmingly likely to get a full-rank matrix if you generate a matrix with iid elements, with no additional constraints:
library(Matrix)
set.seed(101)
r <- replicate(1000,rankMatrix(matrix(rnorm(10000),100)))
table(r) ## all values are equal to 100
(Someone who spent more time on the math might be able to prove that the set of reduced-rank matrices within this space of matrices actually has measure 0 ...)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Is there an easy way to do this in r with a matrix, similar to negative indexing for data.frames?
for example, I can remove the n-th row of the matrix mat as follows:
mat = rbind(mat[1:(n-1),],mat[(n+1):nrow(mat)])
but are there faster and/or simpler ways to do this?
-Paul
Negative indexing works for matrices, i.e. mat[-n,]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Number of digits that are present in the maximum number that is formed using three digits?
Maximum factorial that is formed by three digits?
This was a question asked on a site.
I am not able to understand is there any thing tricky i am not getting?
i have tried 3 and 720 but it is incorrect
The maximum factorial which can be formed using 3 digits is 999!.
The answer can be easily obtained from wolfram alpha.
Number of digits in 999!.
999!=Answer
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I try to calculate, based on given parameters, integer overflow.
for example, if I have an integer than is <= 200, but when I insert it to an unsigned int, it will be > 200. What is the actual arithmetic process for that?
Operations on fixed size integers are usually made modulo 2m, where m is the number of bits (nowadays usually 32 or 64).
This means that a multiple of 2m is added or subtracted from the result to keep it in the range for the type, be it unsigned (0, 2m-1) or signed (-2m-1, 2m-1-1).
You might be interested in the Mathematical foundations of computer integers.