how to get the first 5 letters from an int/string?

how do i get the first 4 or 5 letters from an int? 123456789 or 123456789, what methods are there that will return this?
are we working from an integer or a string?
in this case, it was just an int
Last edited on
Divide by a multiple of ten with a number of zeroes equal to the number of digits you want to skip. Not sure if that's the best way to explain it, so here's an example.

If you have the number 1234 and you want the first digit, you're skipping 3 digits so divide it by 1000. 1234/1000 = 1. If you want the first 2 digits, divide by 100. 1234/100 = 12. Because both operands are ints, the result is a truncated int. This is a simple way to get the first n digits of a number.
Topic archived. No new replies allowed.