BabyFace
asked on
Floats
Hi,
I'm using Visual J++,
and I can't seem to get floats working right!
Here's a piece of code:
float f = 150 / 255;
g.drawString(new Float(f).toString,10,10);
It says 0.0
I'm no mathematician but I'm pretty sure that 150/255 isn't 0.
What's wrong?
Thanks
I'm using Visual J++,
and I can't seem to get floats working right!
Here's a piece of code:
float f = 150 / 255;
g.drawString(new Float(f).toString,10,10);
It says 0.0
I'm no mathematician but I'm pretty sure that 150/255 isn't 0.
What's wrong?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your answer.
Which of the two take up more mem?
I suppose it's double eh?
Thanks again.
Which of the two take up more mem?
I suppose it's double eh?
Thanks again.
int 32 bits
double 64 bits
double 64 bits
float 32 bits
long 64 bits
long 64 bits
double d = 150.0/255.0