What do I want to achieve?
I have a Bank and Wallet system that saves money values. I have the cash and bank datastore working but I’m having issues with the pence bit e.g: £4.50
This is the the current value (With no pence on the end):
And this is what I want on my game.
+1p onto 99p should round it up to 1564 (Nearest pound)
What is the issue?
Every time I test a Rounding Script it has 3 numbers on the end. Like this:
It also only rounds up when there’s a 4th 9 on the end like this
What solutions have you tried so far?
I have tried changing the maths behind it but cant seem to get it working.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I think that switching the division and the multiplication may help. The way you have it currently, it rounds to the nearest 100, instead of to the nearest 0.01 (pence)
Can you please send numbers you are testing with, plus resend the code that you currently have, with any modifications made. I am testing out the code myself and am having no issues with it.
Alternatively, you could just save it as a whole number internally and divide by 100 and show that to players.
So something that shows as a cost of £1.20, you could internally represent as just 120.
So how would that system work when there’s the ability to add and take money from users bank Surely saving it as a decimal number instead of a whole number would be more easier
Saving it as a decimal number WOULD make it a little bit easier, however it means you have to do with floating points.
(Regarding the fix im trying to come up with for the incorrect rounding - is it fine if something like 5.99999999 - bunch of 9s - is rounded up instead of down?)