[Anjuta-list] Anjuta and g++ compile different



Hello everyone,
I have been using anjuta only for a week since I have changed from windows
to Linux(Ubuntu 7.1).
I wrote a little program, which can make the numerator and denominator of a
fraction to integers:

Here is the source:

#include <iostream>
using namespace std;

void make_int(float& numerator,float& denominator)
{
int factor=1;;

float help=numerator;
int* n= new int;
*n=1;
while(1)
{
if(static_cast<int>(numerator)==numerator)
{break;}
factor=(*n);
numerator=help*factor;
*n=*n+1;
}

denominator=denominator*factor;

help=denominator;
factor=1;
*n=1;

while((static_cast<int>(denominator))!=denominator)
{
 factor=(*n);
 denominator=help*factor;
 *n=*n+1;
}
delete n;

numerator*=factor;

cout<<"numerator: "<<numerator<<endl;
cout<<"denominator: "<<denominator<<endl;

}

int main()
{
    float f1=12.1,f2=14.5;
    make_int(f1,f2);
	return 0;
}

My problem is, that this program only works, if I use the shell command "g++
-o fraction fraction.cpp" to compile it:
Then it shows: 

numerator: 121
denominator: 145

But if I compile and run it with anjuta it shows:
numerator: 6.34388e+06
denominator: 7.60218e+06

I do not know the reason for this. I would be glad, if you could tell me,
why anjuta is working so different from g++.
Could you tell me also, if this is also happening on your computer.

PS: I hope you can understand my question, English is not my mother tongue,
therefore there could be some misunderstandings.
-- 
View this message in context: http://www.nabble.com/Anjuta-and-g%2B%2B-compile-different-tp14567861p14567861.html
Sent from the Anjuta - Users mailing list archive at Nabble.com.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]