Is there a *truncate command?

I want to take a variable and just pull out the whole number. Is there a *truncate command or something similar?

Eg:
*truncate (5.2) would give 5
*truncate (5.8) would also give 5

I could likely make something with modulo, but before I do, I figured I should ask what’s out there.

1 Like

I think there might be floor(my_var)…?
But I could be mistaking something that’s internal (can’t check right now). Otherwise modulo.

EDIT: Nah, I’m talking crap. You’ve got round() or modulo.

1 Like
*set temp2 (temp1 modulo 1)
*if temp2 >= 0.5
    *set temp1 ((round(temp1))-1)
*if temp2 < 0.5
    *set temp1 (round(temp1))

This should work, temp1 is the variable you want to round down, and temp2 is just a temp variable.

2 Likes

That looks good. I think my version would have been longer.

Thanks everyone.

1 Like

You can actually make it a one-liner.

*temp floored (myVar - (myVar modulo 1))
3 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.