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.
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 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
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
From the following options, expressed in hexadecimal notation, select the answer which is a normalised floating point number: Pick 1 answer
I know the answer is one but I forgot how to work out this question, can anyone assist?
1.80800000
2.ff800000
3.80080000
4.FFF8FFFF
Normalized values are numbers where the exponent part is between 0x01 and 0xFE. Other exponents have special meanings. The first option has an exponent part of 0x01, the second and fourth options have 0xFF and the third option has 0x00.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I know that (a*b)%M = (a%M * b%M)%M
But what if the equation was :( (a*b)/c )%M ..I dont think I can use the above logic here also..And here M is a non-prime number ..You may assume that (a*b)/c will NEVER end up in a floating value..
For eg:
If a=10 b=9 and c=6,M=4 then (a*b)/c=15 and 15%4=3
but if I use the property as it is with multiplications then ((10%4*9%4)/(6%4))%4= (2*1)/2=1
Please tell me how to solve this kind of problem??
If c and M were relatively prime, you could multiply c^-1%M and the math should work. However, if GCD(c,M)>1, then c^-1%M doesn't exist, and there is no easy way to do it that I know of.
As far as what c^-1%M is, its the number such that c*c^-1%M=1. For example, if c=2 and M=9, 2*5%9=10%9=1, so c^-1%M=5.
You can calculate c^-1%M with the extended euclidean algorithm -- you get ac+bM=1, so ac=1+(-b)M and ac%M=1.