Search code examples
iphoneobjective-ccmath

Getting the first decimal place of a number


I have a number for example: 2.4444444. I need to get first digit after the dot -- in my case it's 4. How to implement it?


Solution

  • How about

    ( (int)(floor( fabs( num ) * 10 ) ) ) % 10