Hey,
I'm writing a program that assigns prime numbers to each entry of a matrix and then I'll need to multiply some of them.
The resulting number grows rapidly and I'm at a loss as to which type to use, as I'm getting "wrap-around" with long double :S
All the help is appreciated.
-Pickel
...
I have two display objects dispObj1, dispObj2.
dispObj2.stage is null. (i.e. it is not added to stage anyhow)
What should be the output of dispObj1.getBounds(dispObj2)?
Is it well defined, or could it be arbitrary?
Once I got x of boundingRectangle close to 6710785, which I guess
is a symptom of an integer overflow somewhere.
But othe...
EDIT Public health warning - this question includes a false assumption about undefined behaviour. See accepted answer.
After a reading recent blog post, I've been thinking a lot about the practicality of avoiding all standards-undefined assumptions in C and C++ code. Here is a snippet cut out of C++, to do an unsigned 128-bit addition.....
Ok, so I have some problems with C++ iostreams that feels very odd, but it is probably defined behaviour, considering this happens with both MSVC++ and G++.
Say I have this program:
#include <iostream>
using namespace std;
int main()
{
int a;
cin >> a;
cout << a << endl;
cin >> a;
cout << a << endl;
return 0;
}
If...
In C# I see that
-1 * int.MinValue == int.MinValue
Is this a bug? It really screwed me up when I was trying to implement a search tree. I ended up using (int.MinValue + 1) so that I could properly negate it.
...
Hi
I am building a unit convertor program that uses the MathFP library.
Typically unit conversion occurs in the formula of:
U1 (unit1) * K (constant) = U2 (unit2)
I want to be able to detect when the an int has over/underflowed?
How can I detect when this has occured and gracefully handle the problem. Ideally I would be looking for ...
I'm trying to learn GCC inline assembly on Linux (x86), and my first experiment was to try and implement integer overflow detection for multiplication. It seems easy enough, but it is having side effects which I don't understand.
So, here I want to multiply two unsigned 8-bit integers, and see if the result overflows. Basically I just...
why this code returns wrong value?
int i=Integer.MAX_VALUE+1;
long l=Integer.MAX_VALUE+1;
System.out.println(l);
System.out.println(i);
...
I am learning computer arithmetic. The book I use(Patterson and Hennessey) lists the below question.
Write mips code to conduct double
precision integer subtraction for
64-bit data. Assume the first operand
to be in registers $t4(hi) and
$t5(lo), second in $t6(hi) and
$t7(lo).
My solution to the answer is
sub $t3, $t5, ...
At first glance, this question may seem like a duplicate of http://stackoverflow.com/questions/199333/best-way-to-detect-integer-overflow-in-c-c, however it is actually significantly different.
I've found that while detecting an unsigned integer overflow is pretty trivial, detecting a signed overflow in C/C++ is actually more difficult ...
I'm making an attempt to learn C++ over again, using Sams Teach Yourself C++ in 21 Days (6th ed.). I'm trying to work through it very thoroughly, making sure I understand each chapter (although I'm acquainted with C-syntax languages already).
Near the start of chapter 5 (Listing 5.2), a point is made about unsigned integer overflow. Bas...