In C#, what\'s the best way to get the 1st digit in an int? The method I came up with is to turn the int into a string, find the 1st char of the string, then turn it back to
The best I can come up with is:
int numberOfDigits = Convert.ToInt32(Math.Floor( Math.Log10( value ) ) ); int firstDigit = value / Math.Pow( 10, numberOfDigits );