How to divide big float
Hello I got a problem with dividing float number !
For example
I hope you get the idea from this Example! QUESTION IS - How do I divide 1,450,343 with 100,000 so that I get 14 and ignore the rest 50,343 cause you can't divide it with 100,000 ! the 14 would be my prestige points after prestige button is pressed
Comment
Best Answer
Answer by BloatedNikNak · Feb 25, 2019 at 12:25 AM
I've never used it, but you could try "MathF.Floor()" - Unity Docs | MathF.Floor
using UnityEngine;
public class PrestigePoints: MonoBehaviour
{
public float myMoney = 1450343;
public float howMuchPrestigePointsWillPlayerGet;
public float prestigePoints = 0;
public float prestigeCost = 100000;
void Update()
{
howMuchPrestigePointsWillPlayerGet = myMoney / prestigeCost;
howMuchPrestigePointsWillPlayerGet = Mathf.Floor(howMuchPrestigePointsWillPlayerGet);
Debug.Log(howMuchPrestigePointsWillPlayerGet);
}
public void letsPrestige()
{
if (myMoney > prestigeCost || myMoney == prestigeCost)
{
prestigePoints += howMuchPrestigePointsWillPlayerGet;
}
}
}
Answer by REICHTAG · Feb 24, 2019 at 01:50 PM
public float myMoney = 1,450,343;
public float howMuchPrestigePointsWillPlayerGet;
public float prestigePoints = 0;
public float prestigeCost = 100,000;
void Update()
{
howMuchPrestigePointsWillPlayerGet = myMoney / prestigeCost;
}
public void letsPrestige()
{
if(myMoney > prestigeCost || myMoney == prestigeCost)
{
prestigePoints += howMuchPrestigePointsWillPlayerGet ;
resetGame();
}
}