Below is the link to a simple project I'm doing to teach myself how to format numbers. The numbers go through a sort of case statement to figure out the end suffix of the number (this isn't my problem though if you guys know of an easier way to do what I've already done, feel free to chime in on that as well).
My problem is that I want the decimal places to be truncated down to the first 3 numbers after the decimal point (thousandths place) but I can't figure out how to do this. I've been searching the forums for awhile now and couldn't find a solution on here or in the manual so if anyone has a solution, I would be very appreciative!
drive.google.com/file/d/0B_fsFsHtHjNqeFFncjNrUFR6NEk/view
Try this:
round(Variable * 1000) / 1000
I'm not sure how that would work with my capx... I'm already using floor to round the numbers?
Develop games in your browser. Powerful, performant & highly capable.
Well, I'm not sure at what point you are using floor but, if you always want the data rounded down, you could just replace the round function to a floor function:
floor(Variable * 1000) / 1000
You could also use regex:
RegexMatchAt(str(yournumber),"\d*(\.\d{1,3})?","g",0)
(yournumber is the variable containing your number). If you always want 3 digits at the end, you have to rewrite it.
You could also use regex: RegexMatchAt(str(yournumber),"\d*(\.\d{1,3})?","g",0) (yournumber is the variable containing your number). If you always want 3 digits at the end, you have to rewrite it.
This actually makes a lot more sense to me. Is that weird? Haha.
I forgot to support minus numbers, so it could be this instead, probably:
RegexMatchAt(str(yournumber),"-?(0|([1-9]\d*))(\.\d+)?","g",0)
I actually have no need for negative numbers but if I ever do, this will come in handy. Haha.