1. ## divide

can I divide a float with another float or with an integer?

I tried the following :
float mean =0;
int number = 0; //initialization... doesnt stay that way
cout <<_" mean : " << mean/number << endl;

and I keep getting the 2 same errors :
stray '\302' in program
stray '\240' in program

what am I doing wrong?

Luigi

2. it might be because you are dividing 0 / 0.

edit: actually, I don't get errors with this code. Is this the whole program?

edit_2: no errors if underscore taken out before string literal.

3. It should work. Dividing by 0 isn't like in math where weird stuff happens. I think a garbage result is returned.

Why is there an underscore after cout<< ?

4. i thought that if you do put a 'f' after the number then it will be a float if you dont it be a double..so it should be like this
Code:
```float mean = 0.0f;

//instead of float mean = 0;```

5. Originally posted by Panopticon
It should work. Dividing by 0 isn't like in math where weird stuff happens.
Actually, very bad stuff happens. When you divide by 0 an exception is thrown, so if you don't try and catch, your program's gonna crash.

6. the underscore shouldnt be there..
error slipped while I typed it..
no I didnt cut and paste..

second : number's value doesnt stay that way like the comment said..
it goes up to 10..
so the error is not 0/0..

I dont have the whole code with me now Ill post it later when I get back home...

In the mean time Ill try float mean = 0.0f;

luigi

7. float mean = 0.0f; isnt going to help that just makes it a float instead of a double.....

8. well guess what..
I just re-tyoed exactly the same thing and now it works!

go wonder...

HO WELL!!!

Luigi
thx all

9. Originally posted by Polymorphic OOP
Actually, very bad stuff happens. When you divide by 0 an exception is thrown, so if you don't try and catch, your program's gonna crash.
Really? I didn't know that. But i remember enterring an int divided by a 0 in my crappy calculator and a garbage result was displayed.