taking zeros away

TackyAttackTackyAttack Member Posts: 141
edited November -1 in Working with GS (Mac)
Is there anyway to take zeros away from a integer,for example, turn 1000 into 1, or 12400 into 124?

Comments

  • dereklaruedereklarue Member Posts: 121
    Yes, You can use / to divide the number.
    Ex:
    In a Display text,
    game.number/100
    if number was 12400 it would display 124
    Hope this helps.
    -derek
  • BeyondtheTechBeyondtheTech Member Posts: 809
    Don't forget to use the floor() to strip out any decimal value.
  • ORBZORBZ Member Posts: 1,304
    I think his problem was that he didn't know how many zeros there would be? i.e. the number could be 1000 with 3 0's or it could be 12400 with two 0's. In which case you wouldn't know to remove 1, 2, or 3 zeros.

    Off the top of my head i'd say you keep removing 1 zero at a time and do a modulus comparison before the division to see if the remainder is 0 or not. If it's not you know you've reached your limit. Ugly hack, I know there has got to be a prettier math solution. I just woke up. :)
  • synthesissynthesis Member Posts: 1,693
    Try doing a loop...

    Divide result by 10
    Is there a remainder/modulus?
    YES...Multiply by 10 - FINISHED
    NO...Loop again.

    Come on fellas...give us a hard one!
  • TackyAttackTackyAttack Member Posts: 141
    I figured out what I needed, it was dividing.
    thanks guys.
Sign In or Register to comment.