using System;
/*
firstDigitAfterDecimal:
-----------------------
Extracts the first digit after the decimal point from a floating‑point number.
Method:
1. Convert the number to a string using ToString().
2. Locate the decimal point.
3. Take the character immediately after it.
4. Convert that character back to an integer.
This approach is simple, expressive, and uses familiar built‑in methods.
*/
class Program
{
static int firstDigitAfterDecimal(float value)
{
string s = value.ToString();
int dotIndex = s.IndexOf(".");
return int.Parse(s.Substring(dotIndex + 1, 1));
}
static void Main()
{
float f = 872.2459f;
int digit = firstDigitAfterDecimal(f);
Console.Write(digit);
}
}
/*
run:
2
*/