R
rleroux
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?
(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?