Dealing with floats in Android (Works ok in Windows)

Previous topic - Next topic

spicypixel

I have an input field and enter the value 2.35, this value is stored in a variable# however when I print this number I get 2.349999905. Now this would be fine if I was displaying a sprite on-screen and works fine for the maths within my application...HOWEVER...

I'm using the float 2.35 to represent £2.35 so when it display £2.349999905 after the user inputs £2.35 it's not the best :-) Any idea of a math fix or a money function anyone could post please. This is the final aspect of my app that is preventing me releasing on the PlayStore presently so any help would be appreciated. Crazy to write my app and test it when its complete I know but my framework scales etc so I don't need to worry too much about testing.

Thanks in advance ;)
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Kitty Hello


spicypixel

http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.