Dear community,
I'm hoping that someone out there might be able to help me solve a problem I've been battling for the past couple of days. I'm trying to update my app for android and ios (link to google play) but I've hit the limit of my understanding of how computers do maths... The app is not a game, it's a time calculator (ie it does base 60 maths for hours and minutes addition and subtraction) and I'm trying to update it to offer decimal hours as an input option. So now I want it to be able to add floating point variables and convert said fractions into hours and minutes (using simple code if possible!).
Presently the data is stored in arrays for hours and minutes and I'm sure I could fudge the current event sheet to make it work - but the OCD parts of my brain want to make the new version look neat and tidy.
The problem is that when using floating point variables, the 'int', 'abs', "%" and other mathematical system expressions aren't reliable for my needs. C2 seems to round variables depending on their context and I'm stuck. Is there a simple and reliable way to convert a number such that the whole number can be displayed in base 10 and the decimal fraction can be converted to base 60... a way that will also work with negative numbers?
Let me elaborate. Subtracting int(N) from N doesn't always give the decimal fraction that remains - see this capx to demonstrate what I mean.
Does this mean that I'm going to have to convert my data into text strings and then manipulate the string to get the answers I want, or can someone think of another way...? If I need to I will, but I'm hoping for an elegant solution...
I've tried following this thread's advice but it doesn't work for me, especially regarding negative numbers:
scirra.com/forum/format-to-2-decimal-places_topic57060.html
Thanks for reading this far!
I know, C2 is meant to build games... I couldn't help myself!