GLBasic forum

Main forum => GLBasic - en => Topic started by: spicypixel on 2013-Jun-20

Title: Dealing with floats in Android (Works ok in Windows)
Post by: spicypixel on 2013-Jun-20
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 ;)
Title: Re: Dealing with floats in Android (Works ok in Windows)
Post by: Kitty Hello on 2013-Jun-20
pounds# = 2.35
format$(0,2,pounds#)
Title: Re: Dealing with floats in Android (Works ok in Windows)
Post by: spicypixel on 2013-Jun-20
Quote from: Kitty Hello on 2013-Jun-20
pounds# = 2.35
format$(0,2,pounds#)

Simple and effective :D