Java is only calculating to once decimal place



I'm doing a calculation with a variable defined as a float.
(e.g. take 5% and add 1)
I should get 1.05

When I print the variable that should hold 1.05, I only get 1.0

Needless to say when I use the variable that should have 1.05 stored,
in the rest of my calculation, I'm getting errounious results (i.e.
cannot divide by 0).

I am inputting a figure (integer) from the that needs to be calculated
as a percent. I store the result in a variable as a float


int entry;
float answer;

answer = 1+(entry/100);

thus if I enter 5...

answer = 1+(5/100)
answer = 1.05

when I have java display answer (System.out.println(answer);) I have
1.0 which thows the rest of my calculation that the above formula is
in, out of whack

I understood floats are suppose to have more than one significant digit?

.



Relevant Pages

  • Re: Float based math class. Is it exist?
    ... > because the processor was doing a double calculation internally ... > Mr.Jon Skeet, ... > I can't image a situation that double is calculated faters than float. ... float precision math is 2x faster than double. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Strange BUG in teh Framework?
    ... and because of the calculation I am using, ... some return "strange" values when cast from single to double. ... it returns a float. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Strange BUG in teh Framework?
    ... and because of the calculation I am using, ... some return "strange" values when cast from single to double. ... it returns a float. ...
    (microsoft.public.dotnet.framework)
  • Re: Strange BUG in teh Framework?
    ... and because of the calculation I am using, ... some return "strange" values when cast from single to double. ... it returns a float. ...
    (microsoft.public.dotnet.general)
  • Re: Float based math class. Is it exist?
    ... because the processor was doing a double calculation internally ... I can't image a situation that double is calculated faters than float. ... Especially dealling directx functions. ... float precision math is 2x faster than double. ...
    (microsoft.public.dotnet.languages.csharp)