[SOLVED] How to display part of number variable of my choosing

Imagine i am printing to text object number variable which value is 333777

How to only display 333
Is it even possible?

For your example, you’ll want to use trunc and divide. Trunc truncates a number so the decimal part is left off. So you’ll want

ToString(trunc(variableNumber/1000))

2 Likes

Sorry my bad
It does exactly what i asked for but i didn’t explain it well and expect it will work both ways

So now i have 333777
Using trunc works perfectly fine as you described
What if my number change to 888333777
I still want it to display only 333

Because right now i will see 888333

In the example is 333 always going to be that number or could it be any number?

Edit: And if not, will you know what number your searching for?

Like always bless you MrMen
ToString(mod(trunc(GlobalVariable(Score)/1000000),1000000))+“,”+ToString(mod(trunc(GlobalVariable(Score)/1000),1000))+“,”+ToString(mod(GlobalVariable(Score),1000))

I was able to abuse modula in conjunction with trunc

And now i am able to display 888333777 as 888,333,777 without using javascript

So yeah adding commas automatically per 3 digits possible without any javascript

1 Like