Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
狙った桁の抽出
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