Skip to content

Instantly share code, notes, and snippets.

@Osinko
Created May 1, 2017 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Osinko/d4f0497942c239e2d1ebee9cbdcb3548 to your computer and use it in GitHub Desktop.
Save Osinko/d4f0497942c239e2d1ebee9cbdcb3548 to your computer and use it in GitHub Desktop.
狙った桁の抽出
using UnityEngine;
using System.Collections;
public class TargetDigit : MonoBehaviour
{
void Start()
{
print(Digit(123456789, 6)); //7桁目を表示(変数digは0を含んでカウントしている)
}
public int Digit(int value, int dig) {
int n=1;
for (int i = 0; i < dig; i++) { n *= 10; }
int temp = value / n;
return temp%10;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment