simple forumlae
Hi i am trying to generate a value based on a percentage. the formulae is percentage / 100 * Total
i use the normal / and * signes but it always returns a zero? i tried to use both a float and a double and no joy.
the problem lies within the division part has it returns zero whenever the correct value is less than 1.0 (ie 0.3, 0.23 etc)
example:
50 / 100 = 0.5
that 0.5 doesnt come up as that, it comes to zero all the time
[462 byte] By [
jonney69a] at [2007-11-27 7:33:58]

# 1
CLDC 1.0 does know anything about floating point calculations, and therefore 50/100 will be 0!if you want a percentage, do your calculation diffrently:(<part>*100/<all>) will do the trick.
# 2
if your phone supports CLDC 1.1, configure your project to use that, otherwise, yup... deepspace is right.
so for your example of:
50/100 = 0
you could just not divide by 100 until after you've finished your calc, so you can possibly be more accurate, but you'll still lose some precision.