Questions tagged [integer-overflow]

Integer overflow occurs when the result of an operation is larger than the maximal value that can be represented by the underlying integer type.

1056 questions
0
votes
2 answers

Everytime I read in through ifstream for a specific input, the input changes, possible int overflow

Every time I use ifstream for input to my program for large inputs, I get something weird. I have a feeling this has to do with integer overflow, but my program still doesn't work with unsigned long long. Here is a simplified version of my code that…
0
votes
1 answer

integer overflow with rollmean in zoo

I have an Integer overflow error with the rollmean function. It's working well when I am doing it on 5 numbers section but not working on a 20 (and 260) number sections. Numbers are trading volumes (7 digits). Do you have any clue to solve this…
0
votes
1 answer

PHP Counter overwraps/overflows only 1 byte of data, counter resets (race condition)

I know this is a simple question but I downloaded a PHP Counter script from http://www.stevedawson.com/scripts/text-counter.php which is the first result on google for PHP counter scripts and it worked great as expected. I tried to see if it messes…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
0
votes
1 answer

How is uint overflow defined in OpenCL?

What happens when the result of a multiplication or sum in OpenCL overflows? Does it wrap? In particular I'd like to know if I can catch an overflow in uint4 x = ( get_global_id( 0 ) * 4 + (uint4)(0, 1, 2, 3) ) * q + r; with int4 invalid = x <…
Mr. Wonko
  • 690
  • 9
  • 17
0
votes
1 answer

Reducing huge user input to limits? (C++)

I have a function in my C++ program that collects one number from the terminal. I want it to accept any number input from the user, reduce numbers outside the signed long long int range to the exact limit, correctly inform the user of any reduction,…
Makst
  • 103
  • 3
0
votes
3 answers

Number overflow in Java

I am tring to implement C/C++ atoi function in Java, below is the code snippet for (int j = 0; j < s.length(); j++) { int digit = Character.digit(s.charAt(j), 10); if (sum < limit/10) { if (neg) return…
thinkman
  • 117
  • 2
  • 13
0
votes
5 answers

Type that can hold the product of two size_t

I have two size_t integers and need to take their product. In what type should I store the result? #include #include #include int main() { typedef std::size_t size_t; typedef unsigned long long product_t; …
Calimo
  • 7,510
  • 4
  • 39
  • 61
0
votes
1 answer

RSA selecting encryption key c++ integer

In my RSA cryptosystem, I am trying to select an encryption key e that is relatively prime to phi(n). phi(n) is the product of two numbers, p-1 & q-1, where p and q are both prime. Those primes are generated using the naive primality test (yes, I…
Caleb Faruki
  • 2,577
  • 3
  • 30
  • 54
0
votes
1 answer

what is the precision difference between a double and a very long integer?

Take 36103009879073133562313702394913733 36103009879073133562313702394913733.0 as an example, What is the difference in precision when representing a very long integer into double in C++?
LCFactorization
  • 1,652
  • 1
  • 25
  • 35
0
votes
2 answers

How to get rid of this overflow error?

I am having a code, which gives incorrect output as i am working with big numbers. I want a solution to this that how could i improve this to accommodate big numbers. Which datatype i should use? CODE: static int get(int n,int i,int digit) …
user
  • 130
  • 9
0
votes
1 answer

Integer power metafunction: detect integer overflow?

Consider the following metafunction that computes the integer power of an integer: template struct integer_power { static constexpr std::intmax_t temporary = integer_power::value; …
Vincent
  • 57,703
  • 61
  • 205
  • 388
0
votes
2 answers

Java, converting epoch to milliseconds

My flot graph is not displaying any lines, problem multiplying epoch by 1000 using Integer in Java? This is my raw data, stored in a .txt file epoch,value 1383229104,55559 1383229121,55559 1383229787,55565 which is parsed by a Servlet and stored…
bobbyrne01
  • 6,295
  • 19
  • 80
  • 150
0
votes
2 answers

php converting string to int not giving the right value

I'm interacting with the facebook api which is sending me back some rather large id for instance $facebook_action['id'] => "123540931515315" intval($facebook_action['id']) gives me "2147483647" In my database I had planned to store it as an integer…
user391986
  • 29,536
  • 39
  • 126
  • 205
0
votes
2 answers

PHP Division returns Floating Value

I am developing a PHP caluclator and I need a clarificator or any other method to do the step which I did now. Below is my situation and solution which I developed. Lets see I am MULTIPLYING two values A,B. $a=1; $b=9; $c= $a * $b; echo "Output :…
DonOfDen
  • 3,968
  • 11
  • 62
  • 112
0
votes
3 answers

Why is my calculated percentage turning negative in Android SDK?

I am hoping that this is going to be a silly thing that I am missing, but I have been banging my head against the keyboard trying to figure out where I am going wrong. I am trying to update a ProgressBar from a DownloadManager in a new Thread. This…
Jay
  • 156
  • 6