By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,110 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,110 IT Pros & Developers. It's quick & easy.

Float question - different compilers

P: n/a
cru
I have a question in regard to floating point calculation behavior
that exists between different compilers on the same hardware. Say, the
difference between a console app written in windows using visaul c++
vs. linux and gcc. I seem to recall running into problems with this in
the past (floating point calculations using different compilers) but I
can't come up with a simple yet concrete example. Any small snippet of
code that exhibits different behavior in regard to floating point
calculations on different compilers would be helpful. Or am I simply
imagining things and there really are no differences?
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"cru" <cr****@yahoo.com> wrote...
I have a question in regard to floating point calculation behavior
that exists between different compilers on the same hardware. Say, the
difference between a console app written in windows using visaul c++
vs. linux and gcc. I seem to recall running into problems with this in
the past (floating point calculations using different compilers) but I
can't come up with a simple yet concrete example. Any small snippet of
code that exhibits different behavior in regard to floating point
calculations on different compilers would be helpful. Or am I simply
imagining things and there really are no differences?


Quite possible. But don't let that stop you. If _you_ find some "small
snippet of code that exhibits", let us know. In all I've seen there are
no differences.

Victor
Jul 19 '05 #2

P: n/a
Hi,

some compilers are converting float internally to double. The following code
will detect this:

#include <iostream>
int main()
{
float fnum = 7.7;
double dnum = 7.7;

double d1 = fnum; // !!!
double d2 = dnum; // !!!

if( d1 == d2 )
std::cout << "The values are equal." << std::endl;
else
std::cout << "The values are NOT equal." << std::endl;

return 0;
}
Ralf
www.oop-trainer.de

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.