how to code can't be devided?

Hi guys,

how to calculate a number can’t be diveded by another number?

ex: 31/3 it’s 1
32/3 it’s 2
13/2 it’s 1

I want to do something like this

var second:float;
var minute:float;
function Start(){
       second = 0;
       minute = 0;
}
function Update(){
         CalculateTime();
         Debug.Log(minute+":"+second);
}
function CalculateTime(){
        second += Timer.deltaTime
        if( Timer ? 60 == 0){
               minute++
         }
}

i forget what’s the name of this operator and what symbol for this kind of calculation.

% - Modulus.

A number that can’t be divided by another number (other than 1 and itself) is called a prime number.

You are describing the remainder of division, which is also called the “modulo” operation (and often incorrectly called the “modulus” operation). It is also common to call it simply the “mod” operator. As npsf3000 already pointed out, the percent-sign, %, is the mod operator in both Javascript and C#, as well as many other languages.

// 32 divided by 3 equals 10 remainder 2
Debug.Log(32 % 3); // Output: 2

Here is one way to code your timer…

var seconds:float = 0;
function Update()
{
     seconds += Timer.deltaTime;
     var m:int = (int)Mathf.Floor(seconds / 60); 
     var s:int = (int)Mathf.Floor(seconds % 60); 
     Debug.Log(m + ":" + s);
}