- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hi,

the question is, whether the floating point division of two integers like this:

int i, j;

//init

float x = ((float) i)/j;

ends up with the exactly same result on any computer within one CPU architecture, one operating system and one compiler. I don't really care what the exact number of the result is, i just need it to be exactly the same on multiple computers with the same architecture(in particular i ask about x86_64).

An example:

I have two computers. Both of them are have x64 Debian. One of them has Intel C2D processor and the other one say AMD Phenom II. Now on C2D i compile a source code stated above. The question is: Will the x variable contain exactly the same result on both of the computers for every possible i and j values(same on both computers of course)? Now, do not consider any compiler optimization - let us say the value of the two variables is not known during compile time... Again, I don't care about the precision of the computation, i just need the values to be the same.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

*Hi,*

the question is, whether the floating point division of two integers like this:

int i, j;

//init

float x = ((float) i)/j;

ends up with the exactly same result on any computer within one CPU architecture, one operating system and one compiler. I don't really care what the exact number of the result is, i just need it to be exactly the same on multiple computers with the same architecture(in particular i ask about x86_64).

An example:

I have two computers. Both of them are have x64 Debian. One of them has Intel C2D processor and the other one say AMD Phenom II. Now on C2D i compile a source code stated above. The question is: Will the x variable contain exactly the same result on both of the computers for every possible i and j values(same on both computers of course)? Now, do not consider any compiler optimization - let us say the value of the two variables is not known during compile time... Again, I don't care about the precision of the computation, i just need the values to be the same.

the question is, whether the floating point division of two integers like this:

int i, j;

//init

float x = ((float) i)/j;

ends up with the exactly same result on any computer within one CPU architecture, one operating system and one compiler. I don't really care what the exact number of the result is, i just need it to be exactly the same on multiple computers with the same architecture(in particular i ask about x86_64).

An example:

I have two computers. Both of them are have x64 Debian. One of them has Intel C2D processor and the other one say AMD Phenom II. Now on C2D i compile a source code stated above. The question is: Will the x variable contain exactly the same result on both of the computers for every possible i and j values(same on both computers of course)? Now, do not consider any compiler optimization - let us say the value of the two variables is not known during compile time... Again, I don't care about the precision of the computation, i just need the values to be the same.

Needless to say, in more realistic context, other issues may come in. We can't guess how you are using this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

In either case, as I mentioned before, you would avoid the reciprocal-math option.

If you have questions about gcc, the more appropriate place is the gcc-help mail list (sign up at gcc.gnu.org).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page